1

Can some take an advice how to add each item to a shopping quote separately, even if add few items per one time?

If override method in a class \Magento\Quote\Model\Quote\Item, it works if add the one product per one time, I mean without using input and set 2 and more (in this case it adds as 2 products to a quote)

public function representProduct($product)
{
    $itemProduct = $this->getProduct();
    if (!$product || $itemProduct->getId() != $product->getId()) {
        return false;
    }

    /**
     * Check maybe product is planned to be a child of some quote item - in this case we limit search
     * only within same parent item
     */
    $stickWithinParent = $product->getStickWithinParent();
    if ($stickWithinParent) {
        if ($this->getParentItem() !== $stickWithinParent) {
            return false;
        }
    }

    // Check options
    $itemOptions = $this->getOptionsByCode();
    $productOptions = $product->getCustomOptions();

    if (!$this->compareOptions($itemOptions, $productOptions)) {
        return false;
    }
    if (!$this->compareOptions($productOptions, $itemOptions)) {
        return false;
    }
    // by default true
    return false;
}
3
  • you want to add same product multiple time? by default two diffrent product adding diffrently in cart.. but same product updated qty. Commented Apr 18, 2018 at 8:20
  • 1
    @Rizwan >you want to add same product multiple time? I need the behaviour when update qty (or add via qty), it should adds as separate items, eg, if add 10 products via qty field, each of the item, should be adding as a separate item to shopping cart. >but same product updated qty. this behaviour, covering in the code above, if add one by one
    – Maxim R
    Commented Apr 18, 2018 at 10:16
  • Hello, @MaximR do you found the solution for this? Because I'm also stacked on this.
    – underser
    Commented Oct 28, 2019 at 16:37

0

Your Answer

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

Browse other questions tagged or ask your own question.