小编Bob*_*bby的帖子

如何在Magento搜索中重置addAttributeToFilter

我在循环中获取addAttributeToFilter函数以在Magento中运行时遇到问题.我在我的商店中有测试数据,以支持搜索以下所有数据;

$attributeSelections=array( array('size' => 44, 'color' => 67, 'manufacturer' => 17),
                        array('size' => 43, 'color' => 69, 'manufacturer' => 17),
                        array('size' => 42, 'color' => 70, 'manufacturer' => 17));
Run Code Online (Sandbox Code Playgroud)

我的代码可以搜索这些组合;

foreach ($attributeSelections as $selection) {
    $searcher = Mage::getSingleton('catalogsearch/advanced')->getProductCollection();
    foreach ($selection as $k => $v) {
        $searcher->addAttributeToFilter("$k", array('eq' => "$v"));
        echo "$k: $v<br />";
    }
    $result=$searcher->getData();
    print_r($result);
}
Run Code Online (Sandbox Code Playgroud)

这个循环给出了以下结果(稍微消毒了veiwing乐趣);

size: 44
color: 67
manufacturer: 17
Array ( [0] => Array ( [entity_id] => 2965 [entity_type_id] => 4 [attribute_set_id] => 28 [type_id] …
Run Code Online (Sandbox Code Playgroud)

php loops magento advanced-search

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

advanced-search ×1

loops ×1

magento ×1

php ×1