本文整理汇总了PHP中Mage_Catalog_Model_Category::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::setData方法的具体用法?PHP Mage_Catalog_Model_Category::setData怎么用?PHP Mage_Catalog_Model_Category::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Category
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Category::setData方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* Serializes the virtual category configuration before it will be saved.
*
* @param Mage_Catalog_Model_Category $object Category saved.
*
* @return Smile_VirtualCategories_Model_Category_Attributes_Backend_Virtual
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getName();
$savedValue = $this->_defaultValue;
$savedValue['is_virtual'] = (bool) $object->getIsVirtual();
if ($object->getVirtualCategoryRule()) {
$savedValue['rule_serialized'] = $object->getVirtualCategoryRule()->getConditions()->asArray();
}
$object->setData($attributeCode, serialize($savedValue));
return $this;
}
示例2: 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;
}
示例3: 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;
}
示例4: getCategoryUrl
/**
* Retrieve Url for specified category
*
* @param Mage_Catalog_Model_Category $category
* @return string
*/
public function getCategoryUrl(Mage_Catalog_Model_Category $category)
{
$url = $category->getData('url');
if (null !== $url) {
return $url;
}
Varien_Profiler::start('REWRITE: ' . __METHOD__);
if ($category->hasData('request_path') && $category->getData('request_path') != '') {
$category->setData('url', $this->_getDirectUrl($category));
Varien_Profiler::stop('REWRITE: ' . __METHOD__);
return $category->getData('url');
}
$requestPath = $this->_getRequestPath($category);
if ($requestPath) {
$category->setRequestPath($requestPath);
$category->setData('url', $this->_getDirectUrl($category));
Varien_Profiler::stop('REWRITE: ' . __METHOD__);
return $category->getData('url');
}
Varien_Profiler::stop('REWRITE: ' . __METHOD__);
$category->setData('url', $category->getCategoryIdUrl());
return $category->getData('url');
}
示例5: _addCategoryUrlPath
/**
* Adds url_path property for non-root category - to ensure that url path is not empty.
*
* Sometimes attribute 'url_path' can be empty, because url_path hasn't been generated yet,
* in this case category is loaded with empty url_path and we should generate it manually.
*
* @param Varien_Object $category
* @return void
*/
protected function _addCategoryUrlPath($category)
{
if (!$category instanceof Varien_Object || $category->getUrlPath()) {
return;
}
// This routine is not intended to be used with root categories,
// but handle 'em gracefully - ensure them to have empty path.
if ($category->getLevel() <= 1) {
$category->setUrlPath('');
return;
}
if (self::$_categoryForUrlPath === null) {
self::$_categoryForUrlPath = Mage::getModel('catalog/category');
}
// Generate url_path
$urlPath = self::$_categoryForUrlPath->setData($category->getData())->getUrlPath();
$category->setUrlPath($urlPath);
}
示例6: testGetLevel
public function testGetLevel()
{
$this->assertEquals(0, $this->_model->getLevel());
$this->_model->setData('level', 1);
$this->assertEquals(1, $this->_model->getLevel());
}
示例7: _setStoreSpecificData
/**
* Set store specific data to category
*
* @param Mage_Catalog_Model_Category $category
* @param Mage_Core_Model_Store $store
* @return Mage_Catalog_Model_Category
*/
protected function _setStoreSpecificData(Mage_Catalog_Model_Category $category, Mage_Core_Model_Store $store)
{
$category->setStoreId($store->getId());
$storeCategoryData = $this->_urlResource->getCategory($category->getId(), $store->getId());
if ($storeCategoryData) {
foreach ($storeCategoryData->toArray() as $key => $data) {
$category->setData($key, $data);
}
}
$rewrites = $this->_categoryRelation->loadByCategory($category);
$category->setRequestPath($rewrites->getRequestPath());
return $category;
}
示例8: testGetAvailableSortBy
public function testGetAvailableSortBy()
{
$this->assertEquals(array(), $this->_model->getAvailableSortBy());
$this->_model->setData('available_sort_by', 'test,and,test');
$this->assertEquals(array('test', 'and', 'test'), $this->_model->getAvailableSortBy());
}
示例9: setCategoryCmsBlock
/**
* @param Mage_Catalog_Model_Category $category
* @param int $cmsBlockId
*/
protected function setCategoryCmsBlock($category, $cmsBlockId)
{
$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);
}
}
示例10: changeCategoryData
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);
}
}
}