Example #1
0
 public function refreshDeal(Varien_Object $_deal)
 {
     //verify if product is enabled for at least one website
     $productStatus = 2;
     $storeIds = explode(',', $_deal->getStores());
     foreach ($storeIds as $storeId) {
         $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($_deal->getProductId());
         if ($product->getStatus() == 1) {
             $productStatus = 1;
             break;
         }
     }
     //verify if product is in stock and if deal qty is higher than 0
     $product = Mage::getModel('catalog/product')->load($_deal->getProductId());
     $stockItem = $product->getStockItem();
     $inStock = $stockItem->getIsInStock() ? true : false;
     if ($attributesArray = $this->checkDealStatus($_deal, $productStatus, $inStock, $product->getTypeId())) {
         if ($attributesArray['disable_product']) {
             //foreach ($storeIds as $storeId) {
             if (Mage::helper('multipledeals')->getMagentoVersion() >= 1324) {
                 Mage::getSingleton('catalog/product_action')->updateAttributes(array($product->getId()), array('status' => 2), 0);
             } else {
                 Mage::getModel('catalog/product_status')->updateProductStatus($product->getId(), 0, 2);
             }
             //}
         }
         $_deal->setStatus($attributesArray['status'])->save();
         Mage::app()->getCacheInstance()->cleanType('collections');
         if (Mage::getConfig()->getModuleConfig('Enterprise_Enterprise')) {
             Mage::getSingleton('enterprise_pagecache/cache')->getCacheInstance()->cleanType('full_page');
         }
     }
 }
 public function render(Varien_Object $row)
 {
     $storeString = $row->getStores();
     $stores = explode(',', $storeString);
     if (in_array('0', $stores)) {
         $show = 'All Store Views';
     } else {
         $storeNames = array();
         foreach ($stores as $storeId) {
             $storeName = Mage::getModel('core/store')->load($storeId)->getName();
             $storeNames[] = $storeName;
         }
         $show = implode(', ', $storeNames);
     }
     return $show;
 }
Example #3
0
 public function runOnStore(Varien_Object $_deal)
 {
     if ($_deal->getStores() != '') {
         $dealStoreIds = array();
         if (strpos($_deal->getStores(), ',')) {
             $dealStoreIds = explode(',', $_deal->getStores());
         } else {
             $dealStoreIds[] = $_deal->getStores();
         }
         $storeId = Mage::app()->getStore()->getId();
         return in_array($storeId, $dealStoreIds) ? true : false;
     }
     return false;
 }