/** * Prepare order item class for adding to cart. * This method takes \XLite\Model\Product class and amount and creates \XLite\Model\OrderItem. * This order item container will be added to cart in $this->addItem() method. * * @param \XLite\Model\Product $product Product class to add to cart OPTIOANL * @param integer $amount Amount of product to add to cart OPTIONAL * * @return \XLite\Model\OrderItem */ protected function prepareOrderItem(\XLite\Model\Product $product = null, $amount = null) { $item = null; if ($product) { $item = new \XLite\Model\OrderItem(); $item->setOrder($this->getCart()); $item->setAttributeValues($product->prepareAttributeValues(\XLite\Core\Request::getInstance()->attribute_values)); $item->setProduct($product); // We make amount correction if there is no such product with additional specifications // which are provided in order item container $newAmount = $this->correctAmountToAdd($item, $amount); if (0 < $newAmount) { $item->setAmount($newAmount); } else { $item->setOrder(null); $item = null; } } return $item; }
/** * {@inheritDoc} */ public function prepareAttributeValues($ids = array()) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareAttributeValues', array($ids)); return parent::prepareAttributeValues($ids); }