【问题标题】:Range filter for custom attribute in magentomagento中自定义属性的范围过滤器
【发布时间】:2015-03-18 17:29:38
【问题描述】:

我需要自定义属性(权重)的范围过滤器,例如价格范围过滤器

我在网址下方使用价格范围过滤器

domain/rings?&price=20000-30000 - working

与我用于重量范围过滤器的相同

domain/rings?&weight=-400-500 - not working

我该如何解决这个问题?

请提出任何过滤体重范围的想法

【问题讨论】:

    标签: php magento filter


    【解决方案1】:

    用于更改属性类型而不删除它为此,您可以在 magento 的根文件夹中创建 .php 文件,然后放入以下代码并在进行所需更改后运行该文件。

    <?php
        require_once '../app/Mage.php';
        Mage::app();
        $installer = new Mage_Eav_Model_Entity_Setup('core_setup');
        $entityTypeId = $installer->getEntityTypeId('catalog_product');
        // replace <my_attribute_code> with your attribute code
       $idAttribute = $installer->getAttribute($entityTypeId,     '<my_attribute_code>', 'attribute_id');
       $installer->updateAttribute($entityTypeId, $idAttribute, array(
       'frontend_input' => 'text',
       'backend_type' => 'decimal',
       ));
      // let's see if it worked
      $attribute =  Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', '<my_attribute_code>');
      Zend_Debug::dump($attribute->getData()); ?>
    

    【讨论】:

      【解决方案2】:

      将分层导航中的使用设置为“可过滤(带有结果)”

      将在搜索结果分层导航中使用权重属性设置为“是”。

      【讨论】:

      • 好的。但请注意,Magento 允许按小数属性(如价格)和下拉属性进行过滤。 weight 属性的类型是什么?
      • 输入类型是文本框,所以我无法将在分层导航中使用设置为“可过滤(带结果)”
      • 哦。好的。所以我认为你需要改变它的类型
      • 如何在没有删除属性的情况下更改类型
      猜你喜欢
      • 2015-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多