1 Comment

Product filtering with multiple attributes

PayPal gateway has rejected request 10413
Magento 2 reindex returns No such entity

I want to display all the product with some product attribute features.

ie; I have 3 products in kids category with attributes and categories like

Category: boy and girl

Size: small, medium,large

color: black,red,white

so I need all the product having Category->boy, Size->small,medium,&color->black,white.

How can it be done?

Related Posts

  • Filtering by attributes (1)
    I have added four different attributes that the user should be able to filter by in the category page, namely size, brand, color and style. All of these attributes are shown correctly on the category page, however they are also all required to be selected in the product page. I only […]
  • Filtering by attributes (1)
    I have added four different attributes that the user should be able to filter by in the category page, namely size, brand, color and style. All of these attributes are shown correctly on the category page, however they are also all required to be selected in the product page. I only […]
  • Create category programmatically in multiple languages in Magento (0)
    Hi guys i am working on magento attributes. I want to get list of all attributes that belongs to two different attribute groups right now i am using this $attributes = Mage::getResourceModel('catalog/product_attribute_collection') […]
  • checkout with multiple addresses according to product categories (0)
    Currently, In "Ship to multiple addresses" section, addresses are displaying for every product in the cart. (If there are 5 products then 5 address fields will display in front of each product). Is it possible to display address fields according to product categories? For ex. if […]
  • How to filter product list by custom attribute on category page in Magento 2? [closed] (0)
    I want to list product by my custom attribute so how can i filter this without changing vendor>magento files. I am displaying my attribute in header. when it changes its filter by my custom attribute. How can i do this?
  • Get Product collection with attribute value equal to null (1)
    I have product attribute called 'category_3' with value 'kids' or null.i wanted only those products with an attribute 'category_3' value equals to null.my query is as follows:- $products = Mage::getModel('catalog/category')->load(40) ->getProductCollection() […]
  • Get highest en lowest value from attribute (1)
    On the category page I have an attribute showing values, that attribute can have multiple values and will show all the values separated by commas. Is there a way to get the highest value from the attribute and also the lowest? What is have to display the values: <?php if […]
  • Attributes not filtering properly on variation (0)
    I have a magento store with multiple variations. If I have two selectable attributes and I select something on the first one it is not filtering the second selection to only include products with the 1st selection. Any ideas? Addition to this I can also select from either dropdown […]
  • creating Configurable products shows products for only one attribute (1)
    I am trying to create a configurable product. I have created 3 attributes and assigned the simple products to each of them. When I want to create a configurable product, if I choose only one of the attributes, the simple products are shown in the "Associated Products". But if I […]
  • Excluding products from multiple categories in collection (1)
    I have a rather specific problem regarding product collections and excluding multiple categories. The following code example does almost exactly what I want to achieve: getting a product collection with the most sold products and excluding all categories that contain the word "free". […]
PayPal gateway has rejected request 10413
Magento 2 reindex returns No such entity

1 Comment on this article

  • User November 12, 2016

    Use below code to filter product collection

    $_productCollection = Mage::getModel('catalog/product')
                    ->getCollection()
                    ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
                    ->addAttributeToSelect('*')
                    ->addAttributeToFilter('category_id','your-category-id')
                    ->addFieldToFilter('size',
                        array(
                            array('eq'=> 'small'),
                            array('eq'=> 'medium')
                        )
                    )
                    ->addFieldToFilter('color',
                        array(
                            array('eq'=> 'black'),
                            array('eq'=> 'white')
                        )
                    );
    

    Hope it will be helpful to you.

    Reply

Add a comment

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax