【问题标题】:Magento - Categories do not show properly in catalogMagento - 类别在目录中未正确显示
【发布时间】:2014-03-10 09:23:23
【问题描述】:

我正在使用带有 Codewix 类别手风琴菜单扩展的 Magento 1.81。

代码: Codewix_Leftmenu_Block_Navigation 类扩展了 Mage_Catalog_Block_Navigation {

 protected $_leftCategories;

/**
 * top level parent category for current category
 *
 * @var int
 */
protected $_parent;

protected function _construct()
{
    $path = $this->getCurrentCategoryPath();
    $parent = $path[count($path)-1];
    if (!$parent) {
        $parent = Mage::app()->getStore()->getRootCategoryId();
    }
    $this->_parent = $parent;
}

public function getBlockTitle() {

}

public $curr_class ="main-categ";

public function  get_categories($categories) {
        $i=0;

        $helper = Mage::helper('catalog/category');

        if($i==0) {
        $ul_id="outer_ul";

        } else {
        $ul_id="inner_ul";
        }
    $array= '<ul id="'.$ul_id.'" class="'.$this->curr_class.'">';
     $this->i++;
    foreach($categories as $category) {
        $cat = Mage::getModel('catalog/category')->load($category->getId());
     if($category->getId() != 1) {
            if($this->isCategoryActive($category)) {
                $this->curr_class = "current";

                } else {
                $this->curr_class = "main-categ";
                }
            if($category->hasChildren()) {

            } else {


            }
        $array .= '<li id="big-categ" style="background-color: red;">'.'<label class="'.$class.'">'.'<a href="'.$helper->getCategoryUrl($category).'">'.$category->getName()."</a> (".$cat->getProductCount().")</label>" . '</li>';
    }
        if($category->hasChildren()) {

            $children = Mage::getModel('catalog/category')->getCategories($category->getId());
             $array .= '<li id="small-categ" style="  visibility: visible;">' . $this->get_categories($children) . '</li>';
            }
         $array .= '</li>';

}
    return  $array . '</ul>';


}

}

输出以下内容

我只想输出

没有 CSS 业务(可见性/显示)

谢谢!

【问题讨论】:

  • 制作 css 以使用此 ul > li > ul 和 ul > li > ul >li 可以添加您的 url。

标签: php css magento


【解决方案1】:

我认为您应该编辑显示手风琴的 .phtml 文件及其类似内容的位置

echo($this->get_Categories($someArrayofAllTopLevelCategories));

改成

$myParticularChildCategories = Mage::getModel('catalog/category')->getCategories([put here the integer ID of the Rochii category]);
echo($this->getCategories($myParticularChildCategories));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多