Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catalog view -> Add configurable to cart does not work #2434

Closed
marvincaspar opened this issue Nov 19, 2015 · 21 comments
Closed

Catalog view -> Add configurable to cart does not work #2434

marvincaspar opened this issue Nov 19, 2015 · 21 comments
Assignees

Comments

@marvincaspar
Copy link

Hi,

I am on the catalog page and want to quick add a product to the cart. It works fine for single products but not for configurables.

I select a color and a size and click Add to Card. Next I am redirected to the product detail page with the following notification:

You need to choose options for your item.

The selected Item is in stock.

@daim2k5 daim2k5 added CS and removed CS labels Nov 19, 2015
@matiasnombarasco
Copy link

Having the same issue in here. Far I can see there is not detail going on the post to the ajax controller. This affects to the EE edition as well.

@matiasnombarasco
Copy link

I found the problem in the template.
magento2/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

The form tag is misplaced.

Pull request in here: #2714

Cheers

matiasnombarasco pushed a commit to matiasnombarasco/magento2 that referenced this issue Dec 15, 2015
Updated template file to support quick add to cart from the category view without being redirected to the product page. This change also fixes the enterprise version. 

Bug related: magento#2434
@tigerx7
Copy link

tigerx7 commented Jan 6, 2016

@matiasnombarasco - I'm still having issues with configurable products and the quick add to cart. I've updated the placement of the form tag and it looks like the values are being posted but the script is redirecting.

Form data being passed to item with one configurable property:
super_attribute[144]: 128, product: 450, uenc: {string}, form_key: {string}

Data gets posted to /{product}?options=cart, and the page returns a 302 Code and redirects to a GET of the same page /{product}?options=cart.

Ironically, at times it does seem to work though on a configurable product. But it's been more like 8/10 times that it won't work. Has the issue returned for you? Perhaps having my frontend completely on SSL may be causing the additional issue for me.

@matiasnombarasco
Copy link

Hi @tigerx7 , that problem didn't happen to me. But for me looks like you are experiencing another issue, not related with this one.

However, looks like the problem might be related with SSL and configuration between secure and insecure urls. I will suggest to check that an also be sure the the ajax urls are under ssl as well. If that doesn't work, is hard to tell what can be the problem.

I will suggest to open another thread and discuss this issue as a separate one and see if someone in the community has the same problem than you.

Good luck!

@tigerx7
Copy link

tigerx7 commented Jan 7, 2016

@matiasnombarasco I think your update on the template definitely fixed half the problem. I did a clean install without SSL to test and sure enough, POST data was missing. I changed the location of the <form> tag, and attributes are now being passed via POST.

However, still was being redirected to product page with "You need to choose options for your item." I found the problem and have been able to reproduce.

Troubleshooting

I happen to come by a configurable product that was actually adding to the cart from the quick add successfully. I compared the items data to one that wasn't working correctly and found a difference in the attributes required_options and has_options.

The one that was working, had both required_options and has_options set to 0. The one that was not working had required_options and has_options set to 1.

I updated the configurable product attribute required_options to 0. After reindexing, I was able to add the configurable product successfully from the quick add to cart in the clean install.

Technically speaking, I'm assuming that indeed configurable products probably should have required_options set to 1? At least I would think so, I'm not sure how the other configurable items had those two attributes set to 0 though. On the production site, items have been added to the catalog via admin and the rest api.

Testing with Clean Install

On the clean install I did to test this, I only added items via admin. I tried both with just clicking "Add Product" which starts it off as a simple product followed by clicking on "Select Configurations" which turns it into a configurable product. I also attempted by clicking "Add Product" -> "Configurable Product" which starts it off as a configurable product directly. I used the already set color attribute, but changed it to a visual swatch prior to creating the products. Both times, the configurable product was created with has_options = 1 and required_options = 1. When testing from the frontend with the correct <form></form> structure, the POST data gets passed but I'm redirected to the product page. However, as soon as I change required_options to 0 and reindex, I'm able to successfully add the product to the cart.

Shorterm Workaround

My short-term solution is going to be to set all the configurable products in the database to required_options = 0; at least until it can be confirmed if this is a bug deeper in the system. Changing this attribute doesn't seem to break "Add to cart" in the product view. Validation still pops up saying fields are required. Only difference I see so far is that add to cart from catalog page now works.

I've kept this reply in this thread since it's still related to the main issue and anyone experiencing this will probably need to both implement #2714 and make sure that the configurable products required_options attribute is set to 0.

@TommyKolkman
Copy link

I have to confirm that the shorterm workaround of tigerx7 is working. For me, this is a pretty problematic one. Any idea if this will be fixed soon? And is there an easier workaround (maybe skip the required options check somewhere?) instead of going into the database every time?

@TommyKolkman
Copy link

Finally "solved" this by setting the value programmatically to 0 in an plugin. In the di.xml of your custom module:

<type name="Magento\Catalog\Model\Product">
    <plugin name="beforeSave" type="Elephant\CFParent\Model\Product" sortOrder="10" disabled="false"/>
</type>

In your own model:


namespace Elephant\CFParent\Model;

class Product
{
   public function afterBeforeSave(\Magento\Catalog\Model\Product $subject, $result)
   {
        /**
         * Temp fix for bug: https://github.com/magento/magento2/issues/2434
         **/

        if( 'configurable' == $subject->getTypeId() ){ 
            $subject->setTypeHasRequiredOptions(false);
            $subject->setRequiredOptions(false);
        }
        return $subject;
   }
}

Good for now, but we need a core fix.

@vzabaznov
Copy link
Contributor

Hi @mc388 you just need to chose all configurable option in configurable product.
If you still have such problems please provide description according to the template, provide the used version, and create new bug.
Closed as not a bug.

@TommyKolkman
Copy link

TommyKolkman commented Jun 22, 2016

Hi @vzabaznov,

I'm not sure this answers all the questions expressed in this thread. Is 2.0.7 now able to add configurable products to the cart directly instead of redirecting to the single page first? Without me having to write a plugin for it?

I cannot find the setting you're describing. Maybe this is different for @matiasnombarasco and @tigerx7?

@kilis
Copy link

kilis commented Sep 7, 2016

This issue is still present in Magento 2.1.1

@rickwhitehead
Copy link

Still an issue in 2.1.1 - can I help?

@TommyKolkman
Copy link

I've provided a work around, and exact description and then this is just ignored, think that's a shame. So like @rickwhitehead states here... Can we help?

@the0ckid82
Copy link

just dropping another confirmation that this is still an issue on 2.1.1

@ps202
Copy link

ps202 commented Oct 6, 2016

@mc388 can you please reopen this? I think it is not resolved...

@TommyKolkman
Copy link

@ps202 I know by now it takes them about three weeks to get to it. So we should wait it out I guess!

@ps202
Copy link

ps202 commented Oct 6, 2016

@TommyKolkman Ok. 👍

@marvincaspar
Copy link
Author

@ps202 I can't reopen this issue, I don't know why

@tanghia
Copy link

tanghia commented Feb 17, 2017

still an issue on Magento 2.1.3 and 2.1.4 !

@marcosdsdba
Copy link

marcosdsdba commented Feb 23, 2017

@TommyKolkman Methods setTypeHasRequiredOptions (false) and setRequiredOptions(false) do not exist !!!

Magento Version : Tests in 2.1.1 and 2.1.4

@natsoman
Copy link

It works in 2.1.5!

@mcretien
Copy link

Still an issue on Magento 2.1.8

magento-engcom-team pushed a commit that referenced this issue Apr 24, 2018
MAGETWO-84209: Impossible specify Bundle option title on store view level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests