public function sales_order_shipment_save_before($observer) { $shipment = $observer->getShipment(); if (!$shipment->getId()) { // this is a new shipment $brandOptionId = Mage::getStoreConfig('arioem/add_to_cart/dummy_product_brand_option_id'); $partNumberOptionId = Mage::getStoreConfig('arioem/add_to_cart/dummy_product_partNo_option_id'); $oemParts = array(); foreach ($shipment->getItemsCollection() as $item) { $productOptions = $item->getOrderItem()->getProductOptions(); if (isset($productOptions['info_buyRequest']['options'])) { $options = $productOptions['info_buyRequest']['options']; $brandName = $options[$brandOptionId]; $brandCode = Vikont_ARIOEM_Model_Source_Oembrand::getOptionCode($brandName); $partNumber = $options[$partNumberOptionId]; $oemParts[$brandCode][$partNumber] = $item->getQty(); } } Mage::helper('arioem/OEM')->decreaseInventoryValues($oemParts); } }
/** * Return customer quote OEM items * * @return array */ public function getCartOEMItems() { if (null === self::$_filteredItems) { self::$_filteredItems = array(); $oemAttrSetId = Mage::getStoreConfig('arioem/add_to_cart/oem_product_attr_set_id'); $items = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems(); $configHelper = Mage::helper('catalog/product_configuration'); $brandOptionId = Mage::getStoreConfig('arioem/add_to_cart/dummy_product_brand_option_id'); $partNumberOptionId = Mage::getStoreConfig('arioem/add_to_cart/dummy_product_partNo_option_id'); foreach ($items as $item) { if ($oemAttrSetId == $item->getProduct()->getAttributeSetId()) { $qty = $item->getQty(); $options = Vikont_ARIOEM_Helper_Data::indexArray($configHelper->getCustomOptions($item), 'option_id'); $brandCode = Vikont_ARIOEM_Model_Source_Oembrand::getOptionCode($options[$brandOptionId]['value']); $partNumber = $options[$partNumberOptionId]['value']; $oemData = $this->getOEMData($brandCode, $partNumber); self::$_filteredItems[$item->getId()] = array('brandCode' => $brandCode, 'partNumber' => $partNumber, 'name' => $item->getName(), 'price' => $item->getPrice(), 'rowTotal' => $item->getRowTotal(), 'qty' => $qty); } } } return self::$_filteredItems; }