/** * Test if the item needs to have its quantity checked for available * inventory. * @param Mage_Sales_Model_Quote_Item $item The item to check * @return bool True if inventory is managed, false if not */ public function isItemInventoried(Mage_Sales_Model_Quote_Item $item) { // never consider a child product as inventoried, allow the parent deal // with inventory and let the child not need to worry about it as the parent // will be the item to keep track of qty being ordered. // Both checks needed as child items will not have a parent item id prior // to being saved and a parent item prior to being added to the parent (e.g. // immediately after being loaded from the DB). if ($item->getParentItemId() || $item->getParentItem()) { return false; } // when dealing with parent items, if any child of the product is managed // stock, consider the entire item as managed stock - allows for the parent // config product in the quote to deal with inventory while allowing child // products to not care individually if ($item->getHasChildren()) { foreach ($item->getChildren() as $childItem) { $childStock = $childItem->getProduct()->getStockItem(); if ($this->isManagedStock($childStock)) { // This Parent is inventoried. Child's ROM setting is 'No backorders', and Manage Stock check hasn't been manually overridden return true; } } // if none of the children were managed stock, the parent is not inventoried return false; } return $this->isManagedStock($item->getProduct()->getStockItem()); }
/** * Get item tax * * @param Mage_Sales_Model_Quote_Item $item * @return int */ public function getItemGiftTax($item) { if ($item->getParentItemId()) { return 0; } $ratesData = $this->_getRates(); $id = $item->getId(); return isset($ratesData['gw_items'][$id]['amt']) ? $ratesData['gw_items'][$id]['amt'] : 0; }
/** * Get item tax * * @param Mage_Sales_Model_Quote_Item $item * @return int */ public function getItemGiftTax($item) { if ($item->getParentItemId()) { return 0; } $key = $this->_getRates($item); $id = $item->getSku(); return isset($this->_rates[$key]['gw_items'][$id]['amt']) ? $this->_rates[$key]['gw_items'][$id]['amt'] : 0; }
/** * @param Mage_Sales_Model_Quote_Item|null $quoteItem * @param $operation * @param array $_defaults * @return array */ public function prepareQuoteItemData(Mage_Sales_Model_Quote_Item $quoteItem = null, $operation, $_defaults = array()) { $_data = array(); $eventParams = array("opportunity_data" => &$_data); switch ($operation) { case self::CREATE_OPPORTUNITY: $_data = array(self::IS_CLOSED => false, self::STAGE => $this->_getHelper()->getHardcodedOpportunityFields("default_stage")); $_paths = Mage::app()->getRequest()->getParam(HooshMarketing_Marketo_Model_Personalize_Category_Path::CATEGORY_PATH); $_data[self::OPPORTUNITY_TYPE] = isset($_paths[$quoteItem->getProduct()->getId()]) ? $_paths[$quoteItem->getProduct()->getId()] : current($this->_getPersonalizeCategoryPathModel()->getPath($quoteItem->getProduct())); break; case self::UPDATE_OPPORTUNITY: if ($quoteItem->getParentItemId()) { $_data[$this->getOpportunityKey()] = $quoteItem->getParentItemId(); } break; } $eventParams["product"] = $quoteItem->getProduct(); if (!$quoteItem->getParentItemId()) { //ignore children quote items $eventParams["quote_item"] = $quoteItem; } Mage::dispatchEvent("opportunity_dynamic_before_{$operation}", $eventParams); if (!empty($_defaults)) { $_data = $_defaults + $_data; //merge defaults and data. Data have priority } if ($quoteItem->getParentItemId()) { $_data[$this->getOpportunityKey()] = $quoteItem->getParentItemId(); } return $_data; }
/** * Add active parent product from item. * * @param Mage_Sales_Model_Quote_Item $item * @return $this */ public function addActiveItemParentProduct($item) { if ($item && $item->getId() && $item->getParentItemId()) { if ($item->getParentItem()->getProduct()->getTypeId() == 'configurable') { // for price calculations to become accurate we need to reload the product, // otherwise things like tier pricing won't be loaded on it and the calculations // will ne dup being incorrect. $this->_activeItemParentProducts[$item->getProduct()->getId()] = Mage::getModel('catalog/product')->load($item->getParentItem()->getProductId()); } } return $this; }