本文整理汇总了PHP中Mage_Catalog_Model_Category::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::getName方法的具体用法?PHP Mage_Catalog_Model_Category::getName怎么用?PHP Mage_Catalog_Model_Category::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Category
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Category::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportData
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);
}
}
}
示例2: getChildCategories
/**
* 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;
}
示例3: purge
/**
* 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;
}
示例4: apply
/**
* 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;
}
示例5: getChildCategories
/**
* 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;
}
示例6: beforeSave
/**
* 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;
}
示例7: beforeSave
/**
* @param Mage_Catalog_Model_Category $object
* @return $this|Convenient_CategoryCode_Model_Attribute_Backend_Code
*
* @author Luke Rodgers <lukerodgers90@gmail.com>
*/
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;
}
示例8: displayCategoryThumbnail
/**
* == 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}' />";
}
示例9: _prepareItemData
/**
* @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;
}
示例10: _getClassNameFromCategoryName
/**
* 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;
}
示例11: testGetName
public function testGetName()
{
$this->assertNull($this->_model->getName());
$this->_model->setData('name', 'test');
$this->assertEquals('test', $this->_model->getName());
}
示例12: getCategoryName
public function getCategoryName(Mage_Catalog_Model_Category $category)
{
return $category->getName();
}
示例13: getName
/**
* Get filter name
*
* @return string
*/
public function getName()
{
return $this->_rootCategory->getName();
}
示例14: array
/**
* 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) {
示例15: array
<?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);
}