daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Dec 12th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $helperToday = Mage::helper('today_special/data');
  2. $arr = $helperToday->getCustomAttributeAndCategoryIdCollection();
  3.    
  4. 017-12-13T05:01:48+00:00 ERR (3): Warning: include(): Failed opening 'Mage/Today/Helper/Data.php' for inclusion (include_path='/opt/bitnami/apps/magento/htdocs/app/code/local:/opt/bitnami/apps/magento/htdocs/app/code/community:/opt/bitnami/apps/magento/htdocs/app/code/core:/opt/bitnami/apps/magento/htdocs/lib:.:/opt/bitnami/php/lib/php:/opt/bitnami/frameworks/smarty/libs')  in /opt/bitnami/apps/magento/htdocs/lib/Varien/Autoload.php on line 94
  5. 2017-12-13T05:02:10+00:00 ERR (3): Warning: include(Mage/Today/Helper/Data.php): failed to open stream: No such file or directory  in /opt/bitnami/apps/magento/htdocs/lib/Varien/Autoload.php on line 94
  6.    
  7. <global>
  8.         <helpers>
  9.           <today_special>
  10.               <class>Today_Special_Helper</class>
  11.           </today_special>
  12.         </helpers>
  13.     </global>
  14.    
  15. <?php
  16. class Today_Special_Helper_Data extends Mage_Core_Helper_Abstract
  17. {
  18.  
  19.      public function getCustomAttributeAndCategoryIdCollection()
  20.      {
  21.         $todayStartOfDayDate  = Mage::app()->getLocale()->date()
  22.                 ->setTime('00:00:00')
  23.                 ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
  24.  
  25.         $todayEndOfDayDate  = Mage::app()->getLocale()->date()
  26.                 ->setTime('23:59:59')
  27.                 ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
  28.         $bundledIds = array();
  29.         $todayIds = array();
  30.         $finalIds();
  31.  
  32.         $_productCollectionForTodaysSpecial = Mage::getModel('catalog/product')
  33.                      ->getCollection()
  34.                      ->joinTable('catalog_category_product', 'product_id=entity_id', array('category_id'=>'category_id'), null, 'left')
  35.                      ->addAttributeToFilter('category_id', array('in' => array('finset' => '20')))
  36.                      ->addAttributeToFilter(array(array('attribute' => 'today_special', 'eq' => '1')))
  37.                      ->addAttributeToFilter('today_special_date', array('or'=> array(
  38.                     0 => array('date' => true, 'to' => $todayEndOfDayDate),
  39.                     1 => array('is' => new Zend_Db_Expr('null')))
  40.                 ), 'left')
  41.                 ->addAttributeToFilter('today_special_end_date', array('or'=> array(
  42.                     0 => array('date' => true, 'from' => $todayStartOfDayDate),
  43.                     1 => array('is' => new Zend_Db_Expr('null')))
  44.                 ), 'left')
  45.                 ->addAttributeToFilter(
  46.                     array(
  47.                         array('attribute' => 'today_special_date', 'is'=>new Zend_Db_Expr('not null')),
  48.                         array('attribute' => 'today_special_end_date', 'is'=>new Zend_Db_Expr('not null')))
  49.                     );
  50.  
  51.                 $_productCollectionForBundledSpecial = Mage::getModel('catalog/product')
  52.                      ->getCollection()
  53.                      ->joinTable('catalog_category_product', 'product_id=entity_id', array('category_id'=>'category_id'), null, 'left')
  54.                      ->addAttributeToFilter('category_id', array('in' => array('finset' => '22')))
  55.                      ->addAttributeToFilter(array(array('attribute' => 'is_bundled', 'eq' => '1')))
  56.                      ->addAttributeToFilter('show_bundled_start_date', array('or'=> array(
  57.                     0 => array('date' => true, 'to' => $todayEndOfDayDate),
  58.                     1 => array('is' => new Zend_Db_Expr('null')))
  59.                 ), 'left')
  60.                 ->addAttributeToFilter('show_bundled_enddate', array('or'=> array(
  61.                     0 => array('date' => true, 'from' => $todayStartOfDayDate),
  62.                     1 => array('is' => new Zend_Db_Expr('null')))
  63.                 ), 'left')
  64.                 ->addAttributeToFilter(
  65.                     array(
  66.                         array('attribute' => 'show_bundled_start_date', 'is'=>new Zend_Db_Expr('not null')),
  67.                         array('attribute' => 'show_bundled_enddate', 'is'=>new Zend_Db_Expr('not null')))
  68.                     );
  69.  
  70.             if(count($_productCollectionForTodaysSpecial)>0)
  71.             {
  72.                 foreach ($_productCollectionForTodaysSpecial as $collection) {
  73.                     foreach ($collection as $data){
  74.                         $todayIds[] = $data['entity_id'];
  75.                     }
  76.                 }
  77.             }
  78.             if(count($_productCollectionForBundledSpecial)>0)
  79.             {
  80.                 foreach ($_productCollectionForBundledSpecial as $collection) {
  81.                     foreach ($collection as $data){
  82.                         $bundledIds[] = $data['entity_id'];
  83.                     }
  84.                 }
  85.             }
  86.  
  87.             if(!empty($bundledIds) && !empty($todayIds))
  88.             {
  89.                 $finalIds = array_unique(array_merge($bundledIds,$todayIds));
  90.             }
  91.             else if(empty($bundledIds) && !empty($todayIds))
  92.             {
  93.                 $finalIds = array_unique($todayIds);
  94.             }
  95.             else if(!empty($bundledIds) && empty($todayIds))
  96.             {
  97.                 $finalIds =  array_unique($bundledIds);
  98.             }
  99.             else
  100.             {
  101.                 $finalIds = array();
  102.             }
  103.  
  104.         return $finalIds;
  105.      }
  106. }
RAW Paste Data
Top