Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $helperToday = Mage::helper('today_special/data');
- $arr = $helperToday->getCustomAttributeAndCategoryIdCollection();
- 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
- 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
- <global>
- <helpers>
- <today_special>
- <class>Today_Special_Helper</class>
- </today_special>
- </helpers>
- </global>
- <?php
- class Today_Special_Helper_Data extends Mage_Core_Helper_Abstract
- {
- public function getCustomAttributeAndCategoryIdCollection()
- {
- $todayStartOfDayDate = Mage::app()->getLocale()->date()
- ->setTime('00:00:00')
- ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
- $todayEndOfDayDate = Mage::app()->getLocale()->date()
- ->setTime('23:59:59')
- ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
- $bundledIds = array();
- $todayIds = array();
- $finalIds();
- $_productCollectionForTodaysSpecial = Mage::getModel('catalog/product')
- ->getCollection()
- ->joinTable('catalog_category_product', 'product_id=entity_id', array('category_id'=>'category_id'), null, 'left')
- ->addAttributeToFilter('category_id', array('in' => array('finset' => '20')))
- ->addAttributeToFilter(array(array('attribute' => 'today_special', 'eq' => '1')))
- ->addAttributeToFilter('today_special_date', array('or'=> array(
- 0 => array('date' => true, 'to' => $todayEndOfDayDate),
- 1 => array('is' => new Zend_Db_Expr('null')))
- ), 'left')
- ->addAttributeToFilter('today_special_end_date', array('or'=> array(
- 0 => array('date' => true, 'from' => $todayStartOfDayDate),
- 1 => array('is' => new Zend_Db_Expr('null')))
- ), 'left')
- ->addAttributeToFilter(
- array(
- array('attribute' => 'today_special_date', 'is'=>new Zend_Db_Expr('not null')),
- array('attribute' => 'today_special_end_date', 'is'=>new Zend_Db_Expr('not null')))
- );
- $_productCollectionForBundledSpecial = Mage::getModel('catalog/product')
- ->getCollection()
- ->joinTable('catalog_category_product', 'product_id=entity_id', array('category_id'=>'category_id'), null, 'left')
- ->addAttributeToFilter('category_id', array('in' => array('finset' => '22')))
- ->addAttributeToFilter(array(array('attribute' => 'is_bundled', 'eq' => '1')))
- ->addAttributeToFilter('show_bundled_start_date', array('or'=> array(
- 0 => array('date' => true, 'to' => $todayEndOfDayDate),
- 1 => array('is' => new Zend_Db_Expr('null')))
- ), 'left')
- ->addAttributeToFilter('show_bundled_enddate', array('or'=> array(
- 0 => array('date' => true, 'from' => $todayStartOfDayDate),
- 1 => array('is' => new Zend_Db_Expr('null')))
- ), 'left')
- ->addAttributeToFilter(
- array(
- array('attribute' => 'show_bundled_start_date', 'is'=>new Zend_Db_Expr('not null')),
- array('attribute' => 'show_bundled_enddate', 'is'=>new Zend_Db_Expr('not null')))
- );
- if(count($_productCollectionForTodaysSpecial)>0)
- {
- foreach ($_productCollectionForTodaysSpecial as $collection) {
- foreach ($collection as $data){
- $todayIds[] = $data['entity_id'];
- }
- }
- }
- if(count($_productCollectionForBundledSpecial)>0)
- {
- foreach ($_productCollectionForBundledSpecial as $collection) {
- foreach ($collection as $data){
- $bundledIds[] = $data['entity_id'];
- }
- }
- }
- if(!empty($bundledIds) && !empty($todayIds))
- {
- $finalIds = array_unique(array_merge($bundledIds,$todayIds));
- }
- else if(empty($bundledIds) && !empty($todayIds))
- {
- $finalIds = array_unique($todayIds);
- }
- else if(!empty($bundledIds) && empty($todayIds))
- {
- $finalIds = array_unique($bundledIds);
- }
- else
- {
- $finalIds = array();
- }
- return $finalIds;
- }
- }
Add Comment
Please, Sign In to add comment