addAttributeToFilter下拉值查询Magento的1.9

问题描述:

滞留在我的Magento的一个问题,目前我正在试图列出在下拉菜单属性“条件”设置为搜索结果“交易所”addAttributeToFilter下拉值查询Magento的1.9

$_productCollection=$this->getLoadedProductCollection(); 
$_productCollection->addAttributeToSelect('*') 
->addAttributeToFilter('condition', array('eq' => 'Exchange')); 

我理解,因为它的一个下拉有一些差异,另外我正在编辑我的list.phtml文件。

这是从搜索的转储输出时的属性refrenced:

([] => Array ([0] => Array ([value] => 6475 [label] => Exchange) [1] => Array ([value] => 6476 [label] => New))) [_attribute:protected] => Mage_Catalog_Model_Resource_Eav_Attribute Object *RECURSION* [_options:protected] => Array ([] => Array ([0] => Array ([value] => 6475 [label] => Exchange) [1] => Array ([value] => 6476 [label] => New)))) [_attributeIdCache:protected] => Array () [_dataTable:protected] => catalog_product_entity_int [_resourceName:protected] => catalog/attribute [_resource:protected] => [_resourceCollectionName:protected] => catalog/attribute_collection [_dataSaveAllowed:protected] => 1 [_isObjectNew:protected] => [_data:protected] => Array ([entity_type_id] => 4 [attribute_code] => condition [attribute_model] => catalog/resource_eav_attribute [backend_model] => eav/entity_attribute_backend_default [backend_type] => int [backend_table] => [frontend_model] => [frontend_input] => select [frontend_label] => Condition [frontend_class] => [source_model] => eav/entity_attribute_source_table [is_required] => 0 [is_user_defined] => 1 [default_value] => 6475 [is_unique] => 0 [note] => [attribute_id] => 152 [frontend_input_renderer] => [is_global] => 1 [is_visible] => 1 [is_searchable] => 1 [is_filterable] => 1 [is_comparable] => 0 [is_visible_on_front] => 1 [is_html_allowed_on_front] => 1 [is_used_for_price_rules] => 0 [is_filterable_in_search] => 1 [used_in_product_listing] => 0 [used_for_sort_by] => 0 [is_configurable] => 1 [apply_to] => [is_visible_in_advanced_search] => 0 [position] => 0 [is_wysiwyg_enabled] => 0 [is_used_for_promo_rules] => 0) [_hasDataChanges:protected] => 1 [_origData:protected] => [_idFieldName:protected] => attribute_id [_isDeleted:protected] => [_oldFieldsMap:protected] => Array () [_syncFieldsMap:protected] => Array ())) 

我会很感激,如果有人能在正确的方向指向我!

谢谢:)

$valueId = 6475; //You can first get the value of label "Exchange". 
//Attribute values are usually stored in eav_attribute_option_value table. 

$_productCollection=$this->getLoadedProductCollection(); 
$_productCollection->addAttributeToSelect('*') 
->addAttributeToFilter('condition', array('eq' => $valueId)); //Use Value Id here instead of the label 
+0

可悲的是这个解决方案没有奏效,它仍然显示为同时设置值的属性效果..真的抓我的头的xD – Nathan 2015-04-09 09:00:15

+0

这是发生,因为您的收藏已经加载。尝试在收集加载之前应用过滤器。 – 2015-04-09 09:45:26