/**
  * Recursively apply custom design settings to product if it's container
  * category custom_use_for_products option is setted to 1.
  * If not or product shows not in category - applyes product's internal settings
  *
  * @deprecated after 1.4.2.0-beta1, functionality moved to Mage_Catalog_Model_Design
  * @param Mage_Catalog_Model_Category|Mage_Catalog_Model_Product $object
  * @param Mage_Core_Model_Layout_Update $update
  */
 protected function _applyCustomDesignSettings($object, $update)
 {
     if ($object instanceof Mage_Catalog_Model_Category) {
         // lookup the proper category recursively
         if ($object->getCustomUseParentSettings()) {
             $parentCategory = $object->getParentCategory();
             if ($parentCategory && $parentCategory->getId() && $parentCategory->getLevel() > 1) {
                 $this->_applyCustomDesignSettings($parentCategory, $update);
             }
             return;
         }
         // don't apply to the product
         if (!$object->getCustomApplyToProducts()) {
             return;
         }
     }
     if ($this->_designProductSettingsApplied) {
         return;
     }
     $date = $object->getCustomDesignDate();
     if (array_key_exists('from', $date) && array_key_exists('to', $date) && Mage::app()->getLocale()->isStoreDateInInterval(null, $date['from'], $date['to'])) {
         if ($object->getPageLayout()) {
             $this->_designProductSettingsApplied['layout'] = $object->getPageLayout();
         }
         $this->_designProductSettingsApplied['update'] = $object->getCustomLayoutUpdate();
     }
 }
 /**
  * Recursively apply custom design settings to category if it's option
  * custom_use_parent_settings is setted to 1 while parent option is not
  *
  * @deprecated after 1.4.2.0-beta1, functionality moved to Mage_Catalog_Model_Design
  * @param Mage_Catalog_Model_Category $category
  * @param Mage_Core_Model_Layout_Update $update
  *
  * @return Mage_Catalog_CategoryController
  */
 protected function _applyCustomDesignSettings($category, $update)
 {
     if ($category->getCustomUseParentSettings() && $category->getLevel() > 1) {
         $parentCategory = $category->getParentCategory();
         if ($parentCategory && $parentCategory->getId()) {
             return $this->_applyCustomDesignSettings($parentCategory, $update);
         }
     }
     $validityDate = $category->getCustomDesignDate();
     if (array_key_exists('from', $validityDate) && array_key_exists('to', $validityDate) && Mage::app()->getLocale()->isStoreDateInInterval(null, $validityDate['from'], $validityDate['to'])) {
         if ($category->getPageLayout()) {
             $this->getLayout()->helper('page/layout')->applyHandle($category->getPageLayout());
         }
         $update->addUpdate($category->getCustomLayoutUpdate());
     }
     return $this;
 }
 protected function exportData(Mage_Catalog_Model_Category $category, $file, $depth = 0)
 {
     $data = array('id' => $category->getId(), 'parent_id' => $category->getParentId(), 'attribute_set_id' => $category->getAttributeSetId(), 'urlPath' => $category->getUrlPath(), 'urlKey' => $category->getUrlKey(), 'path' => $category->getPath(), 'position' => $category->getPosition(), 'page_layout' => $category->getPageLayout(), 'description' => $category->getDescription(), 'display_mode' => $category->getDisplayMode(), 'is_active' => $category->getIsActive(), 'is_anchor' => $category->getIsAnchor(), 'include_in_menu' => $category->getIncludeInMenu(), 'custom_design' => $category->getCustomDesign(), 'level' => $category->getLevel(), 'name' => $category->getName(), 'metaTitle' => $category->getMetaTitle(), 'metaKeywords' => $category->getMetaKeywords(), 'metaDescription' => $category->getMetaDescription());
     echo str_repeat('  ', $depth);
     echo '* ' . $category->getName() . sprintf(' (%s products)', $category->getProductCount()) . PHP_EOL;
     fputcsv($file, $data);
     if ($category->hasChildren()) {
         $children = Mage::getModel('catalog/category')->getCategories($category->getId());
         foreach ($children as $child) {
             $child = Mage::getModel('catalog/category')->load($child->getId());
             $this->exportData($child, $file, $depth + 1);
         }
     }
 }
Exemple #4
0
 /**
  * Extract custom layout settings from category or product object
  *
  * @param Mage_Catalog_Model_Category|Mage_Catalog_Model_Product $object
  * @return Varien_Object
  */
 protected function _extractSettings($object)
 {
     $settings = new Varien_Object();
     if (!$object) {
         return $settings;
     }
     $date = $object->getCustomDesignDate();
     if (array_key_exists('from', $date) && array_key_exists('to', $date) && Mage::app()->getLocale()->isStoreDateInInterval(null, $date['from'], $date['to'])) {
         $settings->setCustomDesign($object->getCustomDesign())->setPageLayout($object->getPageLayout())->setLayoutUpdates((array) $object->getCustomLayoutUpdate());
     }
     return $settings;
 }