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); } } }
/** * Recursively returns a value / label array of all active categories * @param Mage_Catalog_Model_Category $category * @param String $parentname * @return array */ private function getChildCategories($category, $parentname = '') { //category not active - skip it if (!$category->getIsActive()) { return ''; } //array containing all the categories to return $ret = array(); /* Add the current category to return array * Root categories shouldn't be selected */ if ($category->getLevel() > 1) { $ret[$category->getID()] = $category->getName() . $parentname; } // get all children if (Mage::helper('catalog/category_flat')->isEnabled()) { $children = (array) $category->getChildrenNodes(); $childrenCount = count($children); } else { $children = $category->getChildrenCategories(); $childrenCount = $children->count(); } $hasChildren = $children && $childrenCount; // select active children $activeChildren = array(); foreach ($children as $child) { if ($child->getIsActive()) { $activeChildren[] = $child; } } $activeChildrenCount = count($activeChildren); $hasActiveChildren = $activeChildrenCount > 0; /** * Use recursion to include all children categories too */ foreach ($activeChildren as $child) { $childarray = $this->getChildCategories($child, " / " . $category->getName() . $parentname); foreach ($childarray as $k => $v) { $ret[$k] = $v; } } return $ret; }
/** * Purge Category * * @param Mage_Catalog_Model_Category $category * @return Phoenix_VarnishCache_Model_Control_Catalog_Category */ public function purge(Mage_Catalog_Model_Category $category) { if ($this->_canPurge()) { $this->_purgeById($category->getId()); if ($categoryName = $category->getName()) { $this->_getSession()->addSuccess(Mage::helper('varnishcache')->__('Varnish cache for "%s" has been purged.', $categoryName)); } } return $this; }
/** * Apply category filter to layer * * @param Zend_Controller_Request_Abstract $request * @param Mage_Core_Block_Abstract $filterBlock * @return Mage_Catalog_Model_Layer_Filter_Category */ public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { $filter = (int) $request->getParam($this->getRequestVar()); $this->_categoryId = $filter; $this->_appliedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($filter); if ($this->_isValidCategory($this->_appliedCategory)) { $this->getLayer()->getProductCollection()->addCategoryFilter($this->_appliedCategory); $this->getLayer()->getState()->addFilter($this->_createItem($this->_appliedCategory->getName(), $filter)); } return $this; }
/** * Recursively returns a value / label array of all active categories * * @param Mage_Catalog_Model_Category $category * @param String $parentname * @return array */ private function getChildCategories($category, $parentname = '') { //category not active - skip it if (!$category->getIsActive()) { return ''; } //array containing all the categories to return $ret = array(); /* Add the current category to return array * Root categories shouldn't be selected */ if ($category->getLevel() > 1) { $ret[$category->getID()] = ltrim($parentname . " / " . $category->getName(), " / "); } // get all children $children = $category->getChildrenCategories(); $childrenCount = $children->count(); $hasChildren = $children && $childrenCount; // select active children $activeChildren = array(); foreach ($children as $child) { if ($child->getIsActive()) { $activeChildren[] = $child; } } $activeChildrenCount = count($activeChildren); $hasActiveChildren = $activeChildrenCount > 0; /** * Use recursion to include all children categories too */ foreach ($activeChildren as $child) { $childarray = $this->getChildCategories($child, $parentname . " / " . $category->getName()); foreach ($childarray as $k => $v) { $ret[$k] = ltrim($v, " / "); } } return $ret; }
/** * Format url_key value * * @param Mage_Catalog_Model_Category $object * @return Mage_Catalog_Model_Category_Attribute_Backend_Urlkey */ public function beforeSave($object) { $attributeName = $this->getAttribute()->getName(); $urlKey = $object->getData($attributeName); if ($urlKey === false) { return $this; } if ($urlKey == '') { $urlKey = $object->getName(); } if (empty($urlKey)) { $urlKey = Mage::helper('core')->uniqHash(); } $object->setData($attributeName, $object->formatUrlKey($urlKey)); $this->_validateEntityUrl($object); return $this; }
/** * @param Mage_Catalog_Model_Category $object * @return $this|Convenient_CategoryCode_Model_Attribute_Backend_Code * * @author Luke Rodgers <*****@*****.**> */ public function beforeSave($object) { $attributeName = $this->getAttribute()->getName(); $code = $object->getData($attributeName); if ($code === false) { return $this; } if ($code == '') { $code = array(); $parents = $object->getParentCategories(); foreach ($parents as $parent) { if ($parent->getLevel() > 1 && $parent->getId() != $object->getId()) { $code[] = $parent->getName(); } } $code[] = $object->getName(); $code = implode('-', $code); } $object->setData($attributeName, $object->formatUrlKey($code)); return $this; }
/** * == displayCategoryThumbnail * * returns either the category's thumbnail image if it exists * or default to the placeholder image * * @param Mage_Catalog_Model_Category $category * @param integer|string $width # width of the thumbnail * @param integer|string $height # height of the thumbnail * @return string */ public function displayCategoryThumbnail(Mage_Catalog_Model_Category $category, $width = 168, $height = 168) { /** * check if the category's thumbnail exists in the file structure; * if it doesn't then return a placeholder image */ try { $catThumb = $category->getThumbnail(); $filename = $this->getCategoryBaseDir() . $catThumb; if (!empty($catThumb) && file_exists($filename)) { $imgUrl = $this->getCategoryBaseUrl() . $catThumb; } else { $imgUrl = $this->getDefaultCategoryThumbnail($width, $height); } } catch (Exception $e) { Mage::log($e->getMessage()); $imgUrl = $this->getDefaultCategoryThumbnail($width, $height); } $catName = $this->htmlEscape($category->getName()); return $thumb = "<img src='{$imgUrl}' height='{$height}px' width='{$width}px' alt='{$catName}' />"; }
/** * @param Mage_Catalog_Model_Category $category * @param $isSelected * @param int $level * @param bool $isFolded * @param bool $addCount * @return array|null */ protected function _prepareItemData($category, $isSelected, $level = 1, $isFolded = false, $addCount = false) { $row = null; /* * Display only active category and having products or being parents */ if ($category->getIsActive() && (!$addCount || $category->getProductCount())) { $row = array('label' => Mage::helper('core')->htmlEscape($category->getName()), 'value' => $this->getCategoryUrl($category), 'count' => $addCount ? $this->_getProductCount($category) : 0, 'level' => $level, 'id' => $category->getId(), 'parent_id' => $category->getParentId(), 'is_folded' => $isFolded, 'is_selected' => $isSelected); } return $row; }
/** * Convert the category name into a string that can be used as a css class * * @param Mage_Catalog_Model_Category $category * @return string */ protected function _getClassNameFromCategoryName($category) { $name = $category->getName(); $name = preg_replace('/-{2,}/', '-', preg_replace('/[^a-z-]/', '-', strtolower($name))); $name = trim($name, '-'); return $name; }
public function testGetName() { $this->assertNull($this->_model->getName()); $this->_model->setData('name', 'test'); $this->assertEquals('test', $this->_model->getName()); }
public function getCategoryName(Mage_Catalog_Model_Category $category) { return $category->getName(); }
/** * Get filter name * * @return string */ public function getName() { return $this->_rootCategory->getName(); }
/** * Create categories */ $categoriesNumber = 200; $maxNestingLevel = 3; $anchorStep = 2; $nestingLevel = 1; $parentCategoryId = $defaultParentCategoryId = Mage::app()->getStore()->getRootCategoryId(); $nestingPath = "1/{$parentCategoryId}"; $categoryPath = ''; $categoryIndex = 1; $categories = array(); $category = new Mage_Catalog_Model_Category(); while ($categoryIndex <= $categoriesNumber) { $category->setId(null)->setName("Category {$categoryIndex}")->setParentId($parentCategoryId)->setPath($nestingPath)->setLevel($nestingLevel)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setIsAnchor($categoryIndex++ % $anchorStep == 0)->save(); $categoryPath .= '/' . $category->getName(); $categories[] = ltrim($categoryPath, '/'); if ($nestingLevel++ == $maxNestingLevel) { $nestingLevel = 1; $parentCategoryId = $defaultParentCategoryId; $nestingPath = '1'; $categoryPath = ''; } else { $parentCategoryId = $category->getId(); } $nestingPath .= "/{$parentCategoryId}"; } /** * Create products */ $pattern = array('_attribute_set' => 'Default', '_type' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, '_product_websites' => 'base', '_category' => function ($index) use($categories, $categoriesNumber) {
<?php ini_set("memory_limit", "1000M"); require_once "/home/www/demo/app/Mage.php"; umask(0); Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); /* supply parent id */ $parentId = '258'; //$name = 'Mont Blank'; $names = array('Burberry', 'Swarovski', 'Bvlgari', 'Tom Ford', 'Carrera', 'Oakley', 'Chanel', 'Oliver Peoples', 'Dior', 'Paul Smith', 'D&G', 'Polo Ralf Lauren', 'Dsquared', 'Prada', 'Diesel', 'Gucci', 'Ray Ban', 'Tiffany', 'Hugo Boss'); foreach ($names as $name) { $category = new Mage_Catalog_Model_Category(); $category->setName($name); $category->setIsActive(1); $category->setDisplayMode('PAGE'); $category->setIsAnchor(1); $category->setIncludeInMenu(0); $parentCategory = Mage::getModel('catalog/category')->load($parentId); $category->setPath($parentCategory->getPath()); try { $category->save(); echo $category->getName() . ' - ' . $category->getId() . "\n"; } catch (Exception $e) { echo $e->getMessage(); } unset($category); }
/** * Based on provided category object returns small category array with necessary data. * * @param Mage_Catalog_Model_Category $c * @return array */ public function categoryToArray($c) { $category = array(); $category['url'] = $c->getUrl(); $category['name'] = Mage::helper('core')->htmlEscape($c->getName()); $category['image'] = $c->getImage(); $category['thumbnail'] = $c->getThumbnail(); $category['description'] = Mage::helper('core')->htmlEscape($c->getDescription()); $category['meta_description'] = Mage::helper('core')->htmlEscape($c->getMetaDescription()); return $category; }
/** * Data provider * * @return array */ public function prepareLayoutDataProvider() { $urlRewrite = new Mage_Core_Model_Url_Rewrite(); $category = new Mage_Catalog_Model_Category(array('entity_id' => 1, 'name' => 'Test category')); $existingUrlRewrite = new Mage_Core_Model_Url_Rewrite(array('url_rewrite_id' => 1)); return array(array(array('category' => $category, 'url_rewrite' => $urlRewrite), array('selector' => false, 'category_link' => array('name' => $category->getName()), 'back_button' => true, 'save_button' => true, 'reset_button' => false, 'delete_button' => false, 'form' => array('category' => $category, 'url_rewrite' => $urlRewrite), 'categories_tree' => false)), array(array('url_rewrite' => $urlRewrite), array('selector' => true, 'category_link' => false, 'back_button' => true, 'save_button' => false, 'reset_button' => false, 'delete_button' => false, 'form' => false, 'categories_tree' => true)), array(array('url_rewrite' => $existingUrlRewrite, 'category' => $category), array('selector' => false, 'category_link' => array('name' => $category->getName()), 'back_button' => true, 'save_button' => true, 'reset_button' => true, 'delete_button' => true, 'form' => array('category' => $category, 'url_rewrite' => $existingUrlRewrite), 'categories_tree' => false))); }
/** * Set meta description for category * * @param Mage_Catalog_Model_Category $category Category object */ protected function setCategoryMetaDescription(Mage_Catalog_Model_Category $category) { $title = $this->getPhrase(Mage::helper('loewenstark_seo')->getCategoryDescriptionPhrases(), $category->getId()); $title = str_replace(array('{{product_name}}', '{{category_name}}'), $category->getName(), $title); Mage::app()->getLayout()->getBlock('head')->setDescription($title); }
/** * Enter description here... * * @param Mage_Catalog_Model_Category $category * @param int $level * @param boolean $last * @return string */ public function drawItem($category, $level = 0, $last = false) { $html = ''; if (!$category->getIsActive()) { return $html; } if (Mage::helper('catalog/category_flat')->isEnabled()) { $children = $category->getChildrenNodes(); $childrenCount = count($children); } else { $children = $category->getChildren(); $childrenCount = $children->count(); } $hasChildren = $children && $childrenCount; $html .= '<li'; if ($hasChildren || $category->getName() == 'Frames') { $html .= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"'; } $html .= ' class="level' . $level; //$html.= ' nav-'.str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath())); $html .= ' nav-' . $this->_getItemPosition($level); if ($this->isCategoryActive($category)) { $html .= ' active'; } if ($last) { $html .= ' last'; } if ($hasChildren) { $cnt = 0; foreach ($children as $child) { if ($child->getIsActive()) { $cnt++; } } if ($cnt > 0) { $html .= ' parent'; } } $html .= '">' . "\n"; $html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n"; if ($category->getName() != 'Frames') { if ($hasChildren) { $j = 0; $htmlChildren = ''; foreach ($children as $child) { if ($child->getIsActive()) { $htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt); } } if (!empty($htmlChildren)) { $html .= '<ul class="level' . $level . '">' . "\n" . $htmlChildren . '</ul>'; } } } else { $_myStore = Mage::app()->getStore()->getCode(); if ($_myStore == 'wholesaledefault') { $html .= '<ul class="level0"> <li class="level1 nav-1-1"> <a href="' . $this->getBaseURL() . 'frames/mixte-72.html"><span>Mixte</span></a> </li> <li class="level1 nav-1-2"> <a href="' . $this->getBaseURL() . 'frames/polyvalent-55.html"><span>Polyvalent</span></a> </li> <li class="level1 nav-1-3 last"> <a href="' . $this->getBaseURL() . 'frames/rando-74.html"><span>Rando</span></a> </li> </ul>'; } else { $html .= '<ul class="level0"> <li class="level1 nav-1-1"> <a href="' . $this->getBaseURL() . 'frames/mixte-72.html"><span>Mixte</span></a> </li> <li class="level1 nav-1-2"> <a href="' . $this->getBaseURL() . 'frames/polyvalent-55.html"><span>Polyvalent</span></a> </li> <li class="level1 nav-1-3"> <a href="' . $this->getBaseURL() . 'frames/rando-74.html"><span>Rando</span></a> </li> <li class="level1 nav-1-4 last"> <a href="' . $this->getBaseURL() . 'frames/build-kit.html"><span>Build Kits</span></a> </li> </ul>'; } } $html .= '</li>' . "\n"; return $html; }
protected function _prepareItemData(Mage_Catalog_Model_Category $category, $level = 1) { $row = null; $addCount = $this->getCountEnabled(); $isSelected = in_array($category->getId(), $this->getCategories()); $isFolded = $level > 1 && $this->getCategory()->getParentId() != $category->getParentId(); $value = $this->_calculateCategoryValue($category->getId()); if (!$addCount || $category->getProductCount()) { $row = array('label' => Mage::helper('core')->htmlEscape($category->getName()), 'url' => $this->getCategoryUrl($value), 'count' => $addCount ? $this->_getProductCount($category) : 0, 'level' => $level, 'id' => $category->getId(), 'value' => $value, 'parent_id' => $category->getParentId(), 'is_folded' => $isFolded, 'is_selected' => $isSelected); } return $row; }
protected function changeCategoryData(Mage_Catalog_Model_Category $category) { /** @var Amasty_Shopby_Helper_Attributes $helper */ $helper = Mage::helper('amshopby/attributes'); $brand = $helper->getRequestedBrandOption(); $isBrandPage = $brand && $category->getId() == Mage::app()->getStore()->getRootCategoryId(); if ($isBrandPage) { $category->setData('name', $brand->getTitle()); $category->setData('description', $brand->getDescr()); $category->setData('image', $brand->getImgBig() ? '../../amshopby/' . $brand->getImgBig() : null); $category->setData('landing_page', $brand->getCmsBlockId()); } $titles = array(); $descriptions = array(); $imageUrl = null; $cmsBlockId = null; foreach ($this->options as $opt) { /** @var Amasty_Shopby_Model_Value $opt */ if ($isBrandPage && $brand->getId() == $opt->getId()) { // Already applied continue; } if (!$opt->getShowOnList()) { continue; } if ($opt->getTitle()) { $titles[] = $opt->getTitle(); } if ($opt->getDescr()) { $descriptions[] = $opt->getDescr(); } if ($opt->getCmsBlockId()) { $cmsBlockId = $opt->getCmsBlockId(); } if ($opt->getImgBig()) { $imageUrl = '../../amshopby/' . $opt->getImgBig(); } } $position = Mage::getStoreConfig('amshopby/heading/add_title'); if ($titles && $position != Amasty_Shopby_Model_Source_Description_Position::DO_NOT_ADD) { switch ($position) { case Amasty_Shopby_Model_Source_Description_Position::AFTER: array_unshift($titles, $category->getName()); break; case Amasty_Shopby_Model_Source_Description_Position::BEFORE: array_push($titles, $category->getName()); break; } $title = join(Mage::getStoreConfig('amshopby/heading/h1_separator'), $titles); $category->setData('name', $title); } $position = Mage::getStoreConfig('amshopby/heading/add_description'); if ($descriptions && $position != Amasty_Shopby_Model_Source_Description_Position::DO_NOT_ADD) { $oldDescription = $category->getData('description'); $description = '<span class="amshopby-descr">' . join('<br>', $descriptions) . '</span>'; switch ($position) { case Amasty_Shopby_Model_Source_Description_Position::AFTER: $description = $oldDescription ? $oldDescription . '<br>' . $description : $description; break; case Amasty_Shopby_Model_Source_Description_Position::BEFORE: $description = $oldDescription ? $description . '<br>' . $oldDescription : $description; break; case Amasty_Shopby_Model_Source_Description_Position::REPLACE: break; } $category->setData('description', $description); } if (isset($imageUrl) && Mage::getStoreConfig('amshopby/heading/add_image')) { $category->setData('image', $imageUrl); } if (isset($cmsBlockId) && Mage::getStoreConfig('amshopby/heading/add_cms_block')) { $category->setData('landing_page', $cmsBlockId); $mode = $category->getData('display_mode'); if ($mode == Mage_Catalog_Model_Category::DM_PRODUCT) { $category->setData('display_mode', Mage_Catalog_Model_Category::DM_MIXED); } } }
/** * @param Mage_Catalog_Model_Category $category */ protected function _prepareVarsForCategoryApproving(Mage_Catalog_Model_Category $category) { return array('category_name' => $category->getName(), 'category_id' => $category->getId(), 'admin_name' => Mage::getSingleton('admin/session')->getUser()->getName(), 'website' => Mage::getBaseUrl()); }
public function getObject(Mage_Catalog_Model_Category $category) { /** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */ $productCollection = $category->getProductCollection(); $category->setProductCount($productCollection->addMinimalPrice()->count()); $transport = new Varien_Object(); Mage::dispatchEvent('algolia_category_index_before', array('category' => $category, 'custom_data' => $transport)); $customData = $transport->getData(); $storeId = $category->getStoreId(); $category->getUrlInstance()->setStore($storeId); $path = ''; foreach ($category->getPathIds() as $categoryId) { if ($path != '') { $path .= ' / '; } $path .= $this->getCategoryName($categoryId, $storeId); } $image_url = NULL; try { $image_url = $category->getImageUrl(); } catch (Exception $e) { /* no image, no default: not fatal */ } $data = array('objectID' => $category->getId(), 'name' => $category->getName(), 'path' => $path, 'level' => $category->getLevel(), 'url' => $category->getUrl(), '_tags' => array('category'), 'popularity' => 1, 'product_count' => $category->getProductCount()); if (!empty($image_url)) { $data['image_url'] = $image_url; } foreach ($this->config->getCategoryAdditionalAttributes($storeId) as $attribute) { $value = $category->getData($attribute['attribute']); $attribute_ressource = $category->getResource()->getAttribute($attribute['attribute']); if ($attribute_ressource) { $value = $attribute_ressource->getFrontend()->getValue($category); } if (isset($data[$attribute['attribute']])) { $value = $data[$attribute['attribute']]; } if ($value) { $data[$attribute['attribute']] = $value; } } $data = array_merge($data, $customData); foreach ($data as &$data0) { $data0 = $this->try_cast($data0); } return $data; }
echo "Unable to load XML file"; } else { $i = 0; $metaArray = array(); /*** loop over the elements ***/ $metaArray[0][] = 'sku'; $metaArray[0][] = 'meta_title'; $metaArray[0][] = 'meta_description'; $metaArray[0][] = 'meta_keyword'; $j = 1; foreach ($xml as $node) { $catid = $xml->category[$i]->category_id; $category = new Mage_Catalog_Model_Category(); $category->load($catid); //My cat id is 10 $categoryName = $category->getName(); $prodCollection = $category->getProductCollection(); foreach ($prodCollection as $product) { //echo $product->getId()."<br />"; $_product = Mage::getModel('catalog/product')->load($product->getId()); $productSku = $_product->getSku(); $productName = $_product->getName(); $productMetaTitle = str_replace('##productname##', $productName, $xml->category[$i]->meta_title); $productMetaDesc = str_replace('##productname##', $productName, $xml->category[$i]->meta_description); $metaArray[$j][] = $productSku; $metaArray[$j][] = $productMetaTitle; $metaArray[$j][] = $productMetaDesc; $metaArray[$j][] = $xml->category[$i]->meta_keywords; //$prdIds[] = $product->getId(); ///Store all th eproduct id in $prdIds array $j++; }
/** * Format url key of category into valid form * * @param Mage_Catalog_Model_Category $category * @return Mage_Catalog_Model_Category */ protected function _formatUrlKey(Mage_Catalog_Model_Category $category) { if ($category->getUrlKey() == '') { $category->setUrlKey($category->formatUrlKey($category->getName())); } else { $category->setUrlKey($category->formatUrlKey($category->getUrlKey())); } return $category; }
/** * Fill the Field category_name in the given array * 3rd param $isRoot bool default false * * @param Mage_Catalog_Model_Category $category */ protected function _setCategoryName($category) { $this->_defaultRow["category_name"] = $category->getName(); }
/** * Convert the category name into a string that can be used as a css class * * @param Mage_Catalog_Model_Category $category * @return string */ protected function _getClassNameFromCategoryName($category) { $name = $category->getName(); $name = preg_replace('/-{2,}/', '-', preg_replace('/[^a-z-]/', '-', strtolower($name))); while ($name && $name[0] == '-') { $name = substr($name, 1); } while ($name && substr($name, -1) == '-') { $name = substr($name, 0, -1); } return $name; }
protected function changeCategoryData(Mage_Catalog_Model_Category $category) { $brandPageBrand = $this->getCurrentBrandPageBrand(); if ($brandPageBrand) { $category->setData('name', $brandPageBrand->getTitle()); $category->setData('description', $brandPageBrand->getDescr()); $category->setData('image', $brandPageBrand->getImgBig() ? '../../amshopby/' . $brandPageBrand->getImgBig() : null); $category->setData('landing_page', $brandPageBrand->getCmsBlockId()); } $titles = array(); $descriptions = array(); $imageUrl = null; $cmsBlockId = null; foreach ($this->options as $opt) { /** @var Amasty_Shopby_Model_Value $opt */ if ($brandPageBrand && $brandPageBrand->getId() == $opt->getId()) { // Already applied continue; } if (!$opt->getShowOnList()) { continue; } if ($opt->getTitle()) { $titles[] = $opt->getTitle(); } if ($opt->getDescr()) { $descriptions[] = $opt->getDescr(); } if ($opt->getCmsBlockId()) { $cmsBlockId = $opt->getCmsBlockId(); } if ($opt->getImgBig()) { $imageUrl = '../../amshopby/' . $opt->getImgBig(); } } $position = Mage::getStoreConfig('amshopby/heading/add_title'); $title = $this->insertContent($category->getName(), $titles, $position, Mage::getStoreConfig('amshopby/heading/h1_separator')); $category->setData('name', $title); $position = Mage::getStoreConfig('amshopby/heading/add_description'); if ($descriptions && $position != Amasty_Shopby_Model_Source_Description_Position::DO_NOT_ADD) { $oldDescription = $category->getData('description'); $description = '<span class="amshopby-descr">' . join('<br>', $descriptions) . '</span>'; switch ($position) { case Amasty_Shopby_Model_Source_Description_Position::AFTER: $description = $oldDescription ? $oldDescription . '<br>' . $description : $description; break; case Amasty_Shopby_Model_Source_Description_Position::BEFORE: $description = $oldDescription ? $description . '<br>' . $oldDescription : $description; break; case Amasty_Shopby_Model_Source_Description_Position::REPLACE: break; } $category->setData('description', $description); } if (isset($imageUrl) && Mage::getStoreConfig('amshopby/heading/add_image')) { $category->setData('image', $imageUrl); } if (isset($cmsBlockId) && Mage::getStoreConfig('amshopby/heading/add_cms_block')) { $this->setCategoryCmsBlock($category, $cmsBlockId); } }