4

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?

Test site: http://new.keysun.com.au/store/key-sun-zinke-stick-spf-30-5g

5
  • Can you explain executed twice? Are there two requests generated from the same form submission? Check your browser net panel to verify. A shot in the dark: layout update on product level inserting duplicate data.
    – user4351
    Commented Jan 30, 2015 at 8:40
  • Hi @Melvyn, thanks for helping me out. I added more details about "executed twice" adding some logs.
    – Ptitsuisse
    Commented Jan 30, 2015 at 11:04
  • @Melvyn, about the layout suggestion, as I can see the issue with any template even the default Magento one and there seems to be all the good code on the page, I don't think it can be layout related. Or do you have any action or method in mind?
    – Ptitsuisse
    Commented Jan 30, 2015 at 11:14
  • On the product information in the backend, there is a tab for "design", layout updates can be added there. Like I said, shot in the dark, but only database specific thing I could think of that can cause duplicate code to be executed the same layout handle.
    – user4351
    Commented Jan 30, 2015 at 12:02
  • I see. These are all empty (never use them).
    – Ptitsuisse
    Commented Jan 31, 2015 at 5:01

2 Answers 2

8

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.

1
  • You sir, just made my day.
    – Sem
    Commented Nov 25, 2015 at 8:56
0

I was facing the same issue, but in my case after adding a configurable product to the cart, the message "Please specify the product's option(s)" popped-up. After selecting the option and clicking on "Add to Cart" the page showed a loader for 8 to 10 secs and then it faded away, without adding the product to the cart.

After going through the exception.log in var/log, I found this error

ERR (3): exception 'Mage_Core_Exception' with message 'Please specify the product required option(s).' in /home/*****/public_html/app/Mage.php:595

I checked the forum for above error and found your solution

I did the changes in the core file app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php at line 117.

It worked. Thank you very much for this wonderful solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.