本文整理汇总了PHP中Mage_Catalog_Model_Category::getIncludeInMenu方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::getIncludeInMenu方法的具体用法?PHP Mage_Catalog_Model_Category::getIncludeInMenu怎么用?PHP Mage_Catalog_Model_Category::getIncludeInMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Category
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Category::getIncludeInMenu方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isCategoryAcceptable
/**
* Checks if a category matches criteria: active && url_key not null && included in menu if it has to
*/
protected static function isCategoryAcceptable(Mage_Catalog_Model_Category $category = null, $mustBeIncludedInNavigation = true)
{
if (!$category->getIsActive() || is_null($category->getUrlKey()) || $mustBeIncludedInNavigation && !$category->getIncludeInMenu()) {
return false;
}
return true;
}
示例2: drawOpenCategoryItem
/**
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @return string
*/
public function drawOpenCategoryItem($category, $level = 0)
{
if ($this->_isExcluded($category->getId()) || !$category->getIsActive() || !$category->getIncludeInMenu()) {
return '';
}
$cssClass = array('amshopby-cat', 'level' . $level);
$currentCategory = $this->getDataHelper()->getCurrentCategory();
if ($currentCategory->getId() == $category->getId()) {
$cssClass[] = 'active';
}
if ($this->isCategoryActive($category)) {
$cssClass[] = 'parent';
}
if ($category->hasChildren()) {
$cssClass[] = 'has-child';
}
$productCount = '';
if ($this->showProductCount()) {
$productCount = $category->getProductCount();
if ($productCount > 0) {
$productCount = ' <span class="count">(' . $productCount . ')</span>';
} else {
$productCount = '';
}
}
$html = array();
$html[1] = '<a href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . $productCount . '</a>';
$showAll = Mage::getStoreConfig('amshopby/advanced_categories/show_all_categories');
$showDepth = Mage::getStoreConfig('amshopby/advanced_categories/show_all_categories_depth');
$hasChild = false;
$inPath = in_array($category->getId(), $currentCategory->getPathIds());
$showAsAll = $showAll && ($showDepth == 0 || $showDepth > $level + 1);
if ($inPath || $showAsAll) {
$children = $this->_getCategoryCollection()->addIdFilter($category->getChildren());
$this->_addCounts($children);
$children = $this->asArray($children);
if ($children && count($children) > 0) {
$hasChild = true;
$htmlChildren = '';
foreach ($children as $child) {
$htmlChildren .= $this->drawOpenCategoryItem($child, $level + 1);
}
if ($htmlChildren != '') {
$cssClass[] = 'expanded';
$html[2] = '<ol>' . $htmlChildren . '</ol>';
}
}
}
$html[0] = sprintf('<li class="%s">', implode(" ", $cssClass));
$html[3] = '</li>';
ksort($html);
if ($category->getProductCount() || $hasChild && $htmlChildren) {
$result = implode('', $html);
} else {
$result = '';
}
return $result;
}
示例3: 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);
}
}
}
示例4: drawOpenCategoryItem
/**
* Add project specific formatting
*
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param array $levelClass
* @return string
*/
public function drawOpenCategoryItem($category, $level = 0, array $levelClass = NULL)
{
$html = array();
if ($this->_checkLoginCatalog()) {
return '';
}
if (!$category->getIsActive()) {
return '';
}
if (!$category->getIncludeInMenu()) {
return '';
}
if (!isset($levelClass)) {
$levelClass = array();
}
$combineClasses = array();
$combineClasses[] = 'level' . $level;
if ($this->_isCurrentCategory($category)) {
$combineClasses[] = 'active';
} else {
$combineClasses[] = $this->isCategoryActive($category) ? 'parent' : 'inactive';
}
$levelClass[] = implode('-', $combineClasses);
if ($category->hasChildren()) {
$levelClass[] = 'has-children';
}
$levelClass = array_merge($levelClass, $combineClasses);
$levelClass[] = $this->_getClassNameFromCategoryName($category);
$productCount = '';
if ($this->displayProductCount()) {
$num = Mage::getModel('catalog/layer')->setCurrentCategory($category->getId())->getProductCollection()->getSize();
$productCount = '<span class="product-count"> (' . $num . ')</span>';
}
// indent HTML!
$html[1] = str_pad("", $level * 2 + 4, " ") . '<span class="vertnav-cat"><a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->escapeHtml($category->getName()) . '</span></a>' . $productCount . "</span>\n";
$autoMaxDepth = Mage::getStoreConfig('catalog/vertnav/expand_all_max_depth');
$autoExpand = Mage::getStoreConfig('catalog/vertnav/expand_all');
if (in_array($category->getId(), $this->getCurrentCategoryPath()) || $autoExpand && $autoMaxDepth == 0 || $autoExpand && $autoMaxDepth > $level + 1) {
$children = $this->_getCategoryCollection()->addIdFilter($category->getChildren());
$children = $this->toLinearArray($children);
//usort($children, array($this, '_sortCategoryArrayByName'));
$childrenCount = 0;
$hasChildren = $children && ($childrenCount = count($children));
if ($hasChildren) {
$children = $this->toLinearArray($children);
$htmlChildren = '';
foreach ($children as $i => $child) {
$class = array();
if ($childrenCount == 1) {
$class[] = 'only';
} else {
if (!$i) {
$class[] = 'first';
}
if ($i == $childrenCount - 1) {
$class[] = 'last';
}
}
if (isset($children[$i + 1]) && $this->isCategoryActive($children[$i + 1])) {
$class[] = 'prev';
}
if (isset($children[$i - 1]) && $this->isCategoryActive($children[$i - 1])) {
$class[] = 'next';
}
$htmlChildren .= $this->drawOpenCategoryItem($child, $level + 1, $class);
}
if (!empty($htmlChildren)) {
$levelClass[] = 'open';
// indent HTML!
$html[2] = str_pad("", $level * 2 + 2, " ") . '<ul>' . "\n" . $htmlChildren . "\n" . str_pad("", $level * 2 + 2, " ") . '</ul>';
}
}
}
// indent HTML!
$html[0] = str_pad("", $level * 2 + 2, " ") . sprintf('<li class="%s">', implode(" ", $levelClass)) . "\n";
// indent HTML!
$html[3] = "\n" . str_pad("", $level * 2 + 2, " ") . '</li>' . "\n";
ksort($html);
return implode('', $html);
}
示例5: getObject
public function getObject(Mage_Catalog_Model_Category $category)
{
/** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
$productCollection = $category->getProductCollection();
$productCollection = $productCollection->addMinimalPrice();
$category->setProductCount($productCollection->getSize());
$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(), 'include_in_menu' => $category->getIncludeInMenu(), '_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_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;
}
示例6: _setIsActive
/**
* Fill the Field is_active in the given array
* param $isRoot = false not needed here
*
* @param Mage_Catalog_Model_Category $category
*/
protected function _setIsActive($category)
{
$catIds = Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_EXPORT_HIDDEN_CATEGORIES);
$catIdsArray = array();
if (!empty($cat_ids)) {
$catIdsArray = explode(",", $catIds);
foreach ($catIdsArray as &$catId) {
$catId = trim($catId);
}
}
$isActive = $category->getIsActive();
if (in_array($category->getId(), $catIdsArray) || array_intersect($catIdsArray, $category->getParentIds())) {
$isActive = 1;
}
if (Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_EXPORT_NAVIGATION_CATEGORIES_ONLY) && !$category->getIncludeInMenu()) {
$isActive = 0;
}
$this->_defaultRow["is_active"] = $isActive;
}