本文整理汇总了PHP中Magento\Catalog\Model\Category::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getName方法的具体用法?PHP Category::getName怎么用?PHP Category::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Category
的用法示例。
在下文中一共展示了Category::getName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply
/**
* Apply category filter to layer
*
* @param \Zend_Controller_Request_Abstract $request
* @return $this
*/
public function apply(\Zend_Controller_Request_Abstract $request)
{
$filter = (int) $request->getParam($this->getRequestVar());
if (!$filter) {
return $this;
}
$this->_categoryId = $filter;
$this->_coreRegistry->register('current_category_filter', $this->getCategory(), true);
$this->_appliedCategory = $this->_categoryFactory->create()->setStoreId($this->_storeManager->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;
}
示例2: generateUrlKey
/**
* Generate category url key
*
* @param \Magento\Catalog\Model\Category $category
* @return string
*/
public function generateUrlKey($category)
{
$urlKey = $category->getUrlKey();
return $category->formatUrlKey($urlKey === '' || $urlKey === null ? $category->getName() : $urlKey);
}
示例3: isActive
/**
* Get current category
*
* @param \Magento\Catalog\Model\Category $category
*
* @return Category
*/
public function isActive($category)
{
$activeCategory = $this->_coreRegistry->registry('current_category');
$activeProduct = $this->_coreRegistry->registry('current_product');
if (!$activeCategory) {
// Check if we're on a product page
if ($activeProduct !== null) {
return in_array($category->getId(), $activeProduct->getCategoryIds());
}
return false;
}
// Check if this is the active category
if ($this->categoryFlatConfig->isFlatEnabled() && $category->getUseFlatResource() and $category->getId() == $activeCategory->getId()) {
return true;
}
// Check if a subcategory of this category is active
$childrenIds = $category->getAllChildren(true);
if (!is_null($childrenIds) and in_array($activeCategory->getId(), $childrenIds)) {
return true;
}
// Fallback - If Flat categories is not enabled the active category does not give an id
return $category->getName() == $activeCategory->getName() ? true : false;
}
示例4: getObject
public function getObject(Category $category)
{
/** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
$productCollection = $category->getProductCollection();
$productCollection = $productCollection->addMinimalPrice();
$category->setProductCount($productCollection->getSize());
$transport = new DataObject();
$this->eventManager->dispatch('algolia_category_index_before', ['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 = ['objectID' => $category->getId(), 'name' => $category->getName(), 'path' => $path, 'level' => $category->getLevel(), 'url' => $category->getUrl(), 'include_in_menu' => $category->getIncludeInMenu(), '_tags' => ['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_resource = $category->getResource()->getAttribute($attribute['attribute']);
if ($attribute_resource) {
$value = $attribute_resource->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;
}
示例5: testGetName
public function testGetName()
{
$this->assertNull($this->_model->getName());
$this->_model->setData('name', 'test');
$this->assertEquals('test', $this->_model->getName());
}
示例6: getCategoryQueryTerm
public function getCategoryQueryTerm(Category $category, $store = null)
{
$queryType = $this->helper->getCategoryQueryType($store);
if ($queryType == CategoryQueryType::NAME) {
return $category->getName();
}
$parents = $category->getParentCategories();
$parentIds = array_intersect($category->getParentIds(), array_keys($parents));
switch ($queryType) {
case CategoryQueryType::FULL_PATH:
break;
case CategoryQueryType::NAME_AND_PARENT_NAME:
$parentId = $category->getParentId();
$parentIds = in_array($parentId, $parentIds) ? [$parentId] : [];
break;
case CategoryQueryType::NAME_AND_ROOT_NAME:
$parentIds = array_slice($parentIds, 0, 1);
break;
}
$names = array_map(function ($id) use($parents) {
return $parents[$id]->getName();
}, $parentIds);
$names[] = $category->getName();
return implode(' ', $names);
}
示例7: generateCategoryUrlKeyPath
/**
* Generate category url key path
*
* @param \Magento\Catalog\Model\Category $category
* @return string
*/
public function generateCategoryUrlKeyPath($category)
{
$parentPath = $this->categoryHelper->getCategoryUrlPath('', true, $category->getStoreId());
$urlKey = $category->getUrlKey() == '' ? $category->formatUrlKey($category->getName()) : $category->formatUrlKey($category->getUrlKey());
return $parentPath . $urlKey;
}
示例8: getName
/**
* {@inheritdoc}
*/
public function getName()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getName');
if (!$pluginInfo) {
return parent::getName();
} else {
return $this->___callPlugins('getName', func_get_args(), $pluginInfo);
}
}
示例9: getCategoryAsArray
/**
* Convert category to array
*
* @param \Magento\Catalog\Model\Category $category
* @param \Magento\Catalog\Model\Category $currentCategory
* @return array
*/
private function getCategoryAsArray($category, $currentCategory)
{
return ['name' => $category->getName(), 'id' => 'category-node-' . $category->getId(), 'url' => $this->catalogCategory->getCategoryUrl($category), 'has_active' => in_array((string) $category->getId(), explode('/', $currentCategory->getPath()), true), 'is_active' => $category->getId() == $currentCategory->getId()];
}