【问题标题】:Magento - Retrieve Layered Navigation Attribute IDMagento - 检索分层导航属性 ID
【发布时间】:2016-03-04 17:59:19
【问题描述】:

我目前正在使用 Magento CE 1.X,特别是构建一个产品视图,将简单产品包装在其可配置产品中以进行分组显示。

我遇到的问题是分层导航属性仅适用于可配置产品,而不是集中在其中的简单产品。我已经设置了一个过滤器来接受选定的过滤器 ID,但我不知道如何检索 ID 本身。

我正在使用的当前循环是这个......

$appliedFilters = Mage::getSingleton('catalog/layer')->getState()->getFilters();
    foreach ($appliedFilters as $item) {
        $item->getName(); // Retrieves Name
        $item->getLabel(); // Retrieves selected value name
        $item->getFilter()->getRequestVar(); // Retrieves filter code I.E. color
    }

我无法找出用于检索用于过滤集合的选项 id 的方法,我们将不胜感激。

【问题讨论】:

    标签: magento


    【解决方案1】:

    在窥探了 var_dumping $item 吐出的数千行之后,我发现可以使用...访问它。

    $item->getValue();
    

    【讨论】:

      【解决方案2】:

      您可以使用以下代码获取选项项目的attribute_codeattribute_id

      $item->getFilter()->getAttributeModel()->getAttributeCode();
      $item->getFilter()->getAttributeModel()->getAttributeId();
      

      【讨论】:

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