Configurable product with different size adding with different sizes but seems as one product

by Daniel_12   Last Updated June 25, 2018 08:09 AM

I am trying to add Configurable Product in cart on size basis for example if i have product in different sizes and user want 5 of Small and 6 of Large sizes then he can choose quantity and size on product page. When I trying to add them it cart they add as one product instead of two product with different quantity .I am using below logic :

    foreach($optionQty as $key => $qty) {
            if($qty > 0) {
                $params = [
                    'form_key' => $this->formKey->getFormKey(),
                    'product' => $productloaded->getId(),
                    'qty' => $qty,
                    'super_attribute' => [
                        $attributeId => $key
                    ],
                ];
                $productloaded->addCustomOption('additional_options', json_encode($additionalOptions));
                $this->cart->addProduct($productloaded, $params);

            }
 $this->cart->save();

        }

My optionQty array look like below

    Array
(
    [179] => 3
    [180] => 0
    [181] => 3
    [183] => 0
    [184] => 0
    [185] => 3
    [186] => 0
    [187] => 0
    [188] => 0
)

Expected result is 3 product will add to cart but as of now one product is adding with 9 quantity.

Can anyone guide me what I am going wrong here??

Thanks



Related Questions


Is it possible to use two different table rates?

Updated June 22, 2016 08:03 AM




Magento2: Update additional options in cart page

Updated March 16, 2017 11:09 AM