Prestashop Core Application V1.4

Information 'In stock'

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Security Level: All-users
  • Labels:
    None
  • Environment:
    ovh, perso
  • Similar issues:
    PSCFI-1476 Information "In Stock"
    PSCFI-1013 Bad Out of stock information
    PSCFI-973 Stock
    PSCFI-2871 "Notify me when available" should not appear when stock management is disabled
    PSCFI-950 Grammar error �Account Informations
    PSCFI-397 �Informations is not the right word
    PSCFI-3447 Out of stock
    PSCFI-942 information cms block

Description

Hi,
Excuse-me for my english...
In our site in construction (http://www.too-discount.com), there is a problem with the the label (En stock = in stock) and (Epuisé = no more). For example :

  • if you select 'sweat vintage college' in the TAGS block (with the URL parameters "search.php?tag=sweat+vintage+college") then it's impossible to add to cart because there is no more product
  • if you select 'Vêtement / Sweat à capuche' under the CATEGORIES block (URL parameters category.php?id_category=9), then it is possible to add product to cart !!!

We have this product in stock...

Thanks for your help,
Frederic

Activity

Hide
Thomas DIDIERJEAN added a comment - 07/Apr/11 11:58 AM

Hi,
Is this a new install of PrestaShop or an upgrade? Did you install additional modules?

Show
Thomas DIDIERJEAN added a comment - 07/Apr/11 11:58 AM Hi, Is this a new install of PrestaShop or an upgrade? Did you install additional modules?
Hide
case added a comment - 07/Apr/11 12:09 PM

Hi,

I have the same problem than Frederic and other ones (problem listed on french prestashop forum).
I have the new install version 1.4. without any additional modules.
Alex

Show
case added a comment - 07/Apr/11 12:09 PM Hi, I have the same problem than Frederic and other ones (problem listed on french prestashop forum). I have the new install version 1.4. without any additional modules. Alex
Hide
Frédéric Delage added a comment - 07/Apr/11 9:39 PM - edited

Hi,

I found anything...in the mysql db :
by searching in the code, I found php code where IF statement is not satisfied : (tools/smarty/compile/xxxxxxx.file.product-list.tpl.php), line 79 :
if ( ( $_smarty_tpl->tpl_vars['product']->value['allow_oosp'] // 0 (ok)

$_smarty_tpl->tpl_vars['product']->value['quantity']>0 // 0 (the pb is here because we have 2)
)
&&
$_smarty_tpl->tpl_vars['product']->value['customizable']!=2) // 0 (ok)

The Quantity Value is computed by SQL in 'classes/Product.php', line 1995 (function getQuantity) :

SELECT IF(COUNT(id_product_attribute), SUM(pa.`quantity`), p.`quantity`) as total
FROM `ps_product` p LEFT JOIN `ps_product_attribute` AS pa ON pa.`id_product` = p.`id_product`
WHERE p.`id_product` = 23 AND `id_product_attribute` = 1 GROUP BY p.`id_product`

why, in the SQL statement, `id_product_attribute` is set to 1 ????????? If I delete this condition, my result is 2 elements, and this is Ok !

Thanks
Frederic

Show
Frédéric Delage added a comment - 07/Apr/11 9:39 PM - edited Hi, I found anything...in the mysql db : by searching in the code, I found php code where IF statement is not satisfied : (tools/smarty/compile/xxxxxxx.file.product-list.tpl.php), line 79 : if ( ( $_smarty_tpl->tpl_vars['product']->value['allow_oosp'] // 0 (ok)
$_smarty_tpl->tpl_vars['product']->value['quantity']>0 // 0 (the pb is here because we have 2) ) && $_smarty_tpl->tpl_vars['product']->value['customizable']!=2) // 0 (ok) The Quantity Value is computed by SQL in 'classes/Product.php', line 1995 (function getQuantity) : SELECT IF(COUNT(id_product_attribute), SUM(pa.`quantity`), p.`quantity`) as total FROM `ps_product` p LEFT JOIN `ps_product_attribute` AS pa ON pa.`id_product` = p.`id_product` WHERE p.`id_product` = 23 AND `id_product_attribute` = 1 GROUP BY p.`id_product` why, in the SQL statement, `id_product_attribute` is set to 1 ????????? If I delete this condition, my result is 2 elements, and this is Ok ! Thanks Frederic
Hide
Frédéric Delage added a comment - 07/Apr/11 9:58 PM

Hi,

one solution should be :
in controllers/SearchController.php, line 74 :
REPLACE

elseif ($query = Tools::getValue('search_query', Tools::getValue('ref')) AND !is_array($query))
{
$this->productSort();

BY

elseif (($tag = Tools::getValue('tag') AND !is_array($tag)) || ($query = Tools::getValue('search_query', Tools::getValue('ref')) AND !is_array($query)))
{
if($tag = Tools::getValue('tag') AND !is_array($tag))
$query = $tag;
$this->productSort();

Is it a good idea, because in my case it runs correctly ? But I don't know if there are anothers impacts.

Thanks
Fred

Show
Frédéric Delage added a comment - 07/Apr/11 9:58 PM Hi, one solution should be : in controllers/SearchController.php, line 74 : REPLACE elseif ($query = Tools::getValue('search_query', Tools::getValue('ref')) AND !is_array($query)) { $this->productSort(); BY elseif (($tag = Tools::getValue('tag') AND !is_array($tag)) || ($query = Tools::getValue('search_query', Tools::getValue('ref')) AND !is_array($query))) { if($tag = Tools::getValue('tag') AND !is_array($tag)) $query = $tag; $this->productSort(); Is it a good idea, because in my case it runs correctly ? But I don't know if there are anothers impacts. Thanks Fred
Hide
Frédéric Delage added a comment - 08/Apr/11 3:18 PM

Hi,

may be the beginning of the solution...

in the file classes/Search.php, line 425 (function searchTag), 'id_product_attribute' is not returned by the sql and this field is initialize to 1 in the 'getProductProperties' function of the ProductCore class (this is an error).

By modifying these 2 lines, the problem seems to disappear :
line 449 :
REPLACE
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 new

BY
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 new, pa.`id_product_attribute`

and after the line
LEFT JOIN `'.DB_PREFIX.'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.')

add the following line :
LEFT JOIN `'.DB_PREFIX.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1)

It's now possible to add product to cart by searching from TAGS.

Fred

Show
Frédéric Delage added a comment - 08/Apr/11 3:18 PM Hi, may be the beginning of the solution... in the file classes/Search.php, line 425 (function searchTag), 'id_product_attribute' is not returned by the sql and this field is initialize to 1 in the 'getProductProperties' function of the ProductCore class (this is an error). By modifying these 2 lines, the problem seems to disappear : line 449 : REPLACE DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 new BY DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 new, pa.`id_product_attribute` and after the line LEFT JOIN `'.DB_PREFIX.'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.') add the following line : LEFT JOIN `'.DB_PREFIX.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1) It's now possible to add product to cart by searching from TAGS. Fred
Hide
Thomas DIDIERJEAN added a comment - 08/Apr/11 4:29 PM

Can you give me the link to the forum thread?

Show
Thomas DIDIERJEAN added a comment - 08/Apr/11 4:29 PM Can you give me the link to the forum thread?
Hide
Frédéric Delage added a comment - 08/Apr/11 4:30 PM

Hi,

same error when selecting a Manufacturer...even if a product is in stock, it's not possible to add it to the cart.

The problem can be resolved by making the following modifications in the file : classes/Manufacturer.php, function getProducts (line 268) :
REPLACE
(p.`price` * ((100 + (t.`rate`))/100)) AS orderprice

BY
(p.`price` * ((100 + (t.`rate`))/100)) AS orderprice, pa.`id_product_attribute`

and insert the line :
LEFT JOIN `'.DB_PREFIX.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1)

after the last existing LEFT JOIN:
LEFT JOIN `'.DB_PREFIX.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`

Enjoy
Fred

Show
Frédéric Delage added a comment - 08/Apr/11 4:30 PM Hi, same error when selecting a Manufacturer...even if a product is in stock, it's not possible to add it to the cart. The problem can be resolved by making the following modifications in the file : classes/Manufacturer.php, function getProducts (line 268) : REPLACE (p.`price` * ((100 + (t.`rate`))/100)) AS orderprice BY (p.`price` * ((100 + (t.`rate`))/100)) AS orderprice, pa.`id_product_attribute` and insert the line : LEFT JOIN `'.DB_PREFIX.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1) after the last existing LEFT JOIN: LEFT JOIN `'.DB_PREFIX.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` Enjoy Fred
Hide
case added a comment - 12/Apr/11 11:51 AM

Hi,

Fred, your solution added the 08-APR 04.30 pm works well ! Good!
I've just added a "_" beforeDB and after PREFIX.
But if the stock of the default combination ("déclinaison" in french) becomes nul, when selecting a manufacturer, the product becomes out of stock although I have this product in stock in different combinations...

Thomas, maybe you wanted the french forum link ?!
http://www.prestashop.com/forums/viewthread/100770/P15/configuration_et_utilisation_de_prestashop/probleme_de_stock_et_quantite

And on the french forum, someone reports that the problem is the same for the blocks newproducts , bestsales et specials. I didn't check it.

Alex

Show
case added a comment - 12/Apr/11 11:51 AM Hi, Fred, your solution added the 08-APR 04.30 pm works well ! Good! I've just added a "_" beforeDB and after PREFIX. But if the stock of the default combination ("déclinaison" in french) becomes nul, when selecting a manufacturer, the product becomes out of stock although I have this product in stock in different combinations... Thomas, maybe you wanted the french forum link ?! http://www.prestashop.com/forums/viewthread/100770/P15/configuration_et_utilisation_de_prestashop/probleme_de_stock_et_quantite And on the french forum, someone reports that the problem is the same for the blocks newproducts , bestsales et specials. I didn't check it. Alex
Hide
Thomas DIDIERJEAN added a comment - 12/Apr/11 12:30 PM

This bug has been fixed in the development version of PrestaShop, and will be included in the stable release later this month.
For more details you can check my answer in the French forum thread (see case's link).

Show
Thomas DIDIERJEAN added a comment - 12/Apr/11 12:30 PM This bug has been fixed in the development version of PrestaShop, and will be included in the stable release later this month. For more details you can check my answer in the French forum thread (see case's link).
Hide
case added a comment - 12/Apr/11 1:47 PM

Thanks a lot

Show
case added a comment - 12/Apr/11 1:47 PM Thanks a lot

People

Vote (0)
Watch (1)

Dates

  • Created:
    05/Apr/11 10:38 PM
    Updated:
    24/Jan/13 11:34 AM
    Resolved:
    02/Jun/11 9:43 AM