addAttributeToFilter下拉值查询Magento 1.9(addAttributeToFilter dropdown value query Magento 1.9)
在我的Magento中遇到问题,我目前正在尝试列出搜索结果,其中下拉属性'condition'设置为'Exchange'
$_productCollection=$this->getLoadedProductCollection(); $_productCollection->addAttributeToSelect('*') ->addAttributeToFilter('condition', array('eq' => 'Exchange'));我理解,因为它的下拉列表存在一些差异,而且我正在编辑我的list.phtml文件。
这是在引用属性时搜索转储的输出:
( [] => 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 ( ) ) )如果有人能指出我正确的方向,我将不胜感激!
谢谢 :)
Stuck on a problem in my Magento, I am currently trying to list search results where the dropdown attribute 'condition' is set to 'Exchange'
$_productCollection=$this->getLoadedProductCollection(); $_productCollection->addAttributeToSelect('*') ->addAttributeToFilter('condition', array('eq' => 'Exchange'));I understand because its a dropdown there are some differences, plus I am editing my list.phtml file.
This is the output from a dump of the search when the attribute is 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 ( ) ) )I'd be grateful if someone could point me in the right direction!
Thanks :)
最满意答案
$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 $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更多推荐
发布评论