/** * Returns formatted buy request - object, holding request received from * product view page with keys and options for configured product * * @return \Magento\Framework\DataObject */ public function getBuyRequest() { $option = $this->getOptionByCode('info_buyRequest'); $buyRequest = new \Magento\Framework\DataObject($option ? unserialize($option->getValue()) : []); // Overwrite standard buy request qty, because item qty could have changed since adding to quote $buyRequest->setOriginalQty($buyRequest->getQty())->setQty($this->getQty() * 1); return $buyRequest; }
/** * Returns formatted buy request - object, holding request received from * product view page with keys and options for configured product * * @return \Magento\Framework\DataObject */ public function getBuyRequest() { $option = $this->getOptionByCode('info_buyRequest'); $initialData = $option ? unserialize($option->getValue()) : null; if ($initialData instanceof \Magento\Framework\DataObject) { $initialData = $initialData->getData(); } $buyRequest = new \Magento\Framework\DataObject($initialData); $buyRequest->setOriginalQty($buyRequest->getQty())->setQty($this->getQty() * 1); return $buyRequest; }