Example #1
0
 /**
  * Apply design recursively
  *
  * @param Varien_Object $object
  * @param integer $calledFrom
  */
 protected function _applyDesignRecursively($object, $calledFrom = 0)
 {
     $error = 0;
     $package = '';
     $theme = '';
     $design = $object->getCustomDesign();
     $date = $object->getCustomDesignDate();
     $application = $object->getCustomDesignApply();
     $designInfo = explode("/", $design);
     if (count($designInfo) > 1) {
         $package = $designInfo[0];
         $theme = $designInfo[1];
     }
     switch ($calledFrom) {
         case 3:
             if ($application && $application != 1 && $application != 3) {
                 $error = 1;
             }
             $calledFrom = 0;
             break;
         case 4:
             if ($application && $application != 1 && $application != 4) {
                 $error = 1;
             }
             //$calledFrom = 0;
             break;
         default:
             if ($application && $application != 1) {
                 $error = 1;
             }
             break;
     }
     if ($package && $theme) {
         $date['from'] = strtotime($date['from']);
         $date['to'] = strtotime($date['to']);
         if ($date['from'] && $date['from'] > strtotime("today")) {
             $error = 1;
         } else {
             if ($date['to'] && $date['to'] < strtotime("today")) {
                 $error = 1;
             }
         }
         if (!$error) {
             $this->_apply($package, $theme);
             return;
         }
     }
     if ($object instanceof Mage_Catalog_Model_Product) {
         $category = $object->getCategory();
     } else {
         if ($object instanceof Mage_Catalog_Model_Category) {
             $category = $object->getParentCategory();
         }
     }
     if ($category && $category->getId()) {
         $this->_applyDesignRecursively($category, $calledFrom);
     }
 }
Example #2
0
 /**
  * Apply design recursively (if using EAV)
  *
  * @param Varien_Object $object
  * @param int $calledFrom
  * @return Mage_Catalog_Model_Design
  */
 protected function _applyDesignRecursively($object, $calledFrom = 0, $pass = 0)
 {
     $design = $object->getCustomDesign();
     $date = $object->getCustomDesignDate();
     $applyTo = $object->getCustomDesignApply();
     $checkAndApply = $this->_isApplyFor($calledFrom, $applyTo, $pass) && $this->_isApplyDesign($design, $date);
     if ($checkAndApply) {
         return $this;
     }
     $pass++;
     $category = null;
     if ($object instanceof Mage_Catalog_Model_Product) {
         $category = $object->getCategory();
         $pass--;
     } elseif ($object instanceof Mage_Catalog_Model_Category) {
         $category = $object->getParentCategory();
     }
     if ($category && $category->getId()) {
         $this->_applyDesignRecursively($category, $calledFrom, $pass);
     }
     return $this;
 }