Ejemplo n.º 1
0
 public function getBrands()
 {
     $helper = Mage::helper('arioem');
     $brands = $helper->getBrands();
     $currentBrand = $helper->getCurrentBrandName();
     if ($currentBrand) {
         $currentBrandCode = Vikont_ARIOEM_Helper_Data::brandURLNameToARI($currentBrand);
         if ($currentBrandCode && isset($brands[$currentBrandCode])) {
             return array($currentBrandCode => $brands[$currentBrandCode]);
         }
     }
     return $brands;
 }
Ejemplo n.º 2
0
 public function updateAction()
 {
     $data = $this->getRequest()->getPost();
     $response = array('action' => $data['action'], 'errorMessage' => '');
     try {
         switch ($data['action']) {
             case 'update':
                 $updateInfo = array();
                 foreach ($data['items'] as $itemId => $qty) {
                     $updateInfo[$itemId] = array('qty' => max((int) $qty, 1));
                 }
                 $this->_getCart()->updateItems($updateInfo)->save();
                 $this->_getSession()->setCartWasUpdated(true);
                 /*
                 
                 					$quoteItem = $cart->getQuote()->getItemById($id);
                 					if (!$quoteItem) {
                 						Mage::throwException($this->__('Quote item is not found.'));
                 					}
                 					if ($qty == 0) {
                 						$cart->removeItem($id);
                 					} else {
                 						$quoteItem->setQty($qty)->save();
                 					}
                 					$this->_getCart()->save();/**/
                 break;
             case 'delete':
                 $this->_getCart()->removeItem($data['itemId'])->save();
                 break;
             case 'clear':
                 $oemAttrSetId = Mage::getStoreConfig('arioem/add_to_cart/oem_product_attr_set_id');
                 $items = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();
                 foreach ($items as $item) {
                     if ($oemAttrSetId == $item->getProduct()->getAttributeSetId()) {
                         $this->_getCart()->removeItem($item->getId());
                     }
                 }
                 $this->_getCart()->save();
                 break;
             case 'refresh':
             default:
                 // do nothing here
         }
         Mage::register('isAJAX', true);
         $response['html'] = $this->getLayout()->createBlock('arioem/shoppinglist')->toHtml();
     } catch (Exception $e) {
         $response['errorMessage'] = Vikont_ARIOEM_Helper_Data::reportError($e->getMessage());
     }
     $responseAjax = new Varien_Object($response);
     $this->getResponse()->setBody($responseAjax->toJson());
 }
Ejemplo n.º 3
0
 /**
  * Multi add entities data to fulltext search table
  *
  * @param int $storeId
  * @param array $entityIndexes
  * @param string $entity 'product'|'cms'
  * @return Mage_CatalogSearch_Model_Resource_Fulltext_Engine
  */
 public function saveEntityIndexes($storeId, $entityIndexes, $entity = 'product')
 {
     $data = array();
     $storeId = (int) $storeId;
     foreach ($entityIndexes as $entityId => $index) {
         $data[] = array('product_id' => (int) $entityId, 'store_id' => $storeId, 'data_index' => $index);
     }
     if ($data) {
         if ($entity == 'product' && Vikont_ARIOEM_Helper_Data::isEnabled()) {
             $partNumbers = $this->getPartNumbers(array_keys($entityIndexes));
             foreach ($data as $key => &$value) {
                 if (isset($partNumbers[$value['product_id']])) {
                     $value['data_index'] .= self::_getFulltextFieldSeparator() . implode(self::_getFulltextFieldSeparator(), $partNumbers[$value['product_id']]);
                 }
             }
         }
         Mage::getResourceHelper('catalogsearch')->insertOnDuplicate($this->getMainTable(), $data, array('data_index'));
     }
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 public static function isEnabled()
 {
     if (null === self::$isEnabled) {
         self::$isEnabled = (bool) Mage::getStoreConfig('arioem/general/enabled');
     }
     return self::$isEnabled;
 }
Ejemplo n.º 6
0
 public function getBrandName()
 {
     $this->getBrand();
     return Vikont_ARIOEM_Helper_Data::brandARICode2Name($this->_brand);
 }