/** * Imports quote items for gift messages from products data * * @param mixed $products * @return $this */ public function importAllowQuoteItemsFromProducts($products) { $allowedItems = $this->getAllowQuoteItems(); $deleteAllowedItems = []; foreach ($products as $productId => $data) { $product = $this->productRepository->getById($productId, false, $this->_session->getStore()->getId()); $item = $this->_getQuote()->getItemByProduct($product); if (!$item) { continue; } if (in_array($item->getId(), $allowedItems) && !isset($data['giftmessage'])) { $deleteAllowedItems[] = $item->getId(); } elseif (!in_array($item->getId(), $allowedItems) && isset($data['giftmessage'])) { $allowedItems[] = $item->getId(); } } $allowedItems = array_diff($allowedItems, $deleteAllowedItems); $this->setAllowQuoteItems($allowedItems); return $this; }
/** * Initialize data for price rules * * @return $this */ public function initRuleData() { $this->_coreRegistry->register('rule_data', new \Magento\Framework\DataObject(['store_id' => $this->_session->getStore()->getId(), 'website_id' => $this->_session->getStore()->getWebsiteId(), 'customer_group_id' => $this->getCustomerGroupId()])); return $this; }
/** * Retrieve quote store object * * @return \Magento\Store\Model\Store */ public function getStore() { return $this->_sessionQuote->getStore(); }