addAttributeToFilter下拉值查询Magento 1.9(addAttributeToFilter dropdown value query Magento 1.9)

编程入门 行业动态 更新时间:2024-10-27 16:35:04
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

更多推荐

本文发布于:2023-04-29 05:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335279.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Magento   addAttributeToFilter   query   dropdown

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!