Magento Please specify the product’s option(s) Masalah dan Penangananya

I just upgraded a site from 1.6.2 to 1.9.1 I have a big issue with configurable products. Impossible to add them to the cart. I always get "Please specify the product's option(s)." There is no error in system.log or exception.log
848  
       

I just upgraded a site from 1.6.2 to 1.9.1 I have a big issue with configurable products. Impossible to add them to the cart. I always get “Please specify the product’s option(s).”

There is no error in system.log or exception.log

Test I’ve done so far:

  • it seems not theme related: on the updated site I have the issue with all themes I use (even default Magento or RWD).
  • I have not modified 1 single line from default 1.9.1 Magento install.
  • If I test a fresh 1.9.1 Magento install (not with our old database) I have no issues (so not server related).
  • the POST call to add product to the cart seems correct (contains form_key, product id and attribute).
  • all caches and all indexes have been refreshed and refreshed and refreshed.
  • disabled all extensions.

So I think the issue comes from the database as I’m using the 1.9.1 files with the 1.6.2 database. The database has been upgraded the first time I opened the site. I tired that upgrade multiple times and always face the issue. Because of all the testing I’ve done I think it can only be related to something not setup properly in the database: something in the database that has not upgraded and is not compatible with the 1.9.1 files.

So I also tried the following:

  • I created a new configurable product on the new install with a new created attibute. Same issue.
  • I added custom logging to some “Add to cart” functions and compared logs to same process on a fresh install. I can see some differences there but can’t explain them. On the install with the issue, the Add to cart process seems to be executed twice. The first time the $buyRequest variable seems to have the correct settings including attribute value but the second time the $buyRequest seems to have no attribute value any more and therefore the function returns “Please specify the product’s option(s).”. The last function executed is _prepareProduct (from app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php). On the new install that function is executed twice (and on all working installs it’s only executed once).

EDIT: added more details about “executed twice”.

If I check the net debuger in browser or using Fiddler, there is only 1 POST request.

If I add some debug logging in the _prepareProduct function like:

Mage::log("######  Start _prepareProduct ######");
$attributes = $buyRequest->getSuperAttribute(); (first line of code of the function)
Mage::log($attributes);
$r = debug_backtrace();foreach($r as $s){Mage::log($s['file']);Mage::log($s['line']);}

It logs

2015-01-30T10:54:46+00:00 DEBUG (7): ######  Start _prepareProduct ######
2015-01-30T10:54:46+00:00 DEBUG (7): Array
(
    [141] => 274
)

2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php
2015-01-30T10:54:46+00:00 DEBUG (7): 410
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Sales/Model/Quote.php
2015-01-30T10:54:46+00:00 DEBUG (7): 969
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Sales/Model/Quote.php
2015-01-30T10:54:46+00:00 DEBUG (7): 1046
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Checkout/Model/Cart.php
2015-01-30T10:54:46+00:00 DEBUG (7): 265
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Checkout/controllers/CartController.php
2015-01-30T10:54:46+00:00 DEBUG (7): 218
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Core/Controller/Varien/Action.php
2015-01-30T10:54:46+00:00 DEBUG (7): 418
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
2015-01-30T10:54:46+00:00 DEBUG (7): 250
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Core/Controller/Varien/Front.php
2015-01-30T10:54:46+00:00 DEBUG (7): 172
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Core/Model/App.php
2015-01-30T10:54:46+00:00 DEBUG (7): 354
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/app/Mage.php
2015-01-30T10:54:46+00:00 DEBUG (7): 684
2015-01-30T10:54:46+00:00 DEBUG (7): /home/keysun/public_html/new/index.php
2015-01-30T10:54:46+00:00 DEBUG (7): 87
2015-01-30T10:54:46+00:00 DEBUG (7): result1
2015-01-30T10:54:54+00:00 DEBUG (7): ######  Start _prepareProduct ######
2015-01-30T10:54:54+00:00 DEBUG (7): 
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php
2015-01-30T10:54:54+00:00 DEBUG (7): 410
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Sales/Model/Quote.php
2015-01-30T10:54:54+00:00 DEBUG (7): 969
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Sales/Model/Quote.php
2015-01-30T10:54:54+00:00 DEBUG (7): 1046
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Checkout/Model/Cart.php
2015-01-30T10:54:54+00:00 DEBUG (7): 265
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Checkout/controllers/CartController.php
2015-01-30T10:54:54+00:00 DEBUG (7): 218
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Core/Controller/Varien/Action.php
2015-01-30T10:54:54+00:00 DEBUG (7): 418
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
2015-01-30T10:54:54+00:00 DEBUG (7): 250
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Core/Controller/Varien/Front.php
2015-01-30T10:54:54+00:00 DEBUG (7): 172
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/code/core/Mage/Core/Model/App.php
2015-01-30T10:54:54+00:00 DEBUG (7): 354
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/app/Mage.php
2015-01-30T10:54:54+00:00 DEBUG (7): 684
2015-01-30T10:54:54+00:00 DEBUG (7): /home/keysun/public_html/new/index.php
2015-01-30T10:54:54+00:00 DEBUG (7): 87
2015-01-30T10:54:54+00:00 DEBUG (7): result3

Notes on the above log: – same debug code on a normal fresh install will only log the 1st part until result1. – in the first part you can see that the $attributes variable contains attribute value (that is good) but in the second it’s gone and that’s why it returns “Please specify the product’s option(s).”. – there is a huge time gap between the 2 parts of 8s (I logged deeper in the function like router (app/code/core/Mage/Core/Controller/Varien/Router/Standard.php) and they seem to be executed around 80 times. That could be an issue but I have no clue about how Magento routers work or how to debug further). So I don’t know why it’s executed twice but that seems the cause of the error message.

  • removed all extension and custom tables from the database
  • checked structure of database (fresh 1.9.1 install vs upgraded 1.6.2 install). There are a lot of differences like default value and some fields that are not there but they are for tables that seems to not impact products.

Has someone faced the same issue? or has any clue why settings in the database could change the Add to cart behaviour for configurable products?

 

Finally found the cause of the above issue: shopping cart rules with a category condition

 

First I installed xdebug to try to find out what was going on. I found out that the the Subselect.php and Combine.php files were in an infinite loop when adding a configurable product to the cart. Looking for that issue I found this post: Magento debug trace That post refers to “have a sales rule with a subselection of categories, I ran into the OPs issue with an infinite loop.”

So I removed the shopping cart rules that had a category condition and then it work perfectly. I was able to add any configurable product to the cart again. But I need the shopping rules I used. Adding a new one didn’t work: if the shopping cart rule had a category condition, impossible to add configurable product to the cart. Without a category condition, no issues.

The fix module from Briand Litzinger (or Husseycoding) didn’t fix the issue for me. But by changing the core file:

app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php

From:

if (parent::validate($item)) {

To:

if (Mage_Rule_Model_Condition_Combine::validate($item)) {

Fixed the issue and I’m able to use cart rules with a category condition and add a configurable product to the cart.

There seems to ba several bug reports open against 1.9.1 that are not fixed yet.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>