2022 Developer Survey is open! Take survey.

Questions tagged [addattributetofilter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
44 views

Magento 2: addAttributeToFilter not working when filtering by ID

Exception #0 (Magento\Framework\Exception\LocalizedException): The "id" attribute name is invalid. Reset the name and try again. Here is my code ... \Magento\Catalog\Model\ResourceModel\...
user avatar
  • 738
1 vote
2 answers
67 views

addAttributeToFilter for Multislect Attribute Update Query Magento 2

I have Multiselect product attribute and i want to filter product by that attribute. Currently i am using below code, $productCollection = $this->getLayer()->getProductCollection(); $...
user avatar
0 votes
0 answers
45 views

Filter product collection with nested OR/AND statements

I want to make a query as below WHERE manageStock = 0 OR (manageStock = 1 AND productStatus != 0) OR (manageStock = 1 AND backorderStatus = 1) but I can't use $collection->getSelect()->where() ...
user avatar
0 votes
3 answers
35 views

Magento 2 addAttributeToFilter not adding to SQL

I'm trying to get a list of products with a custom attribute set a certain way. Right now only one product should be returned, however it's returning the whole catalog. It seems like my added ...
user avatar
  • 527
0 votes
2 answers
197 views

Set order for product Collection in magento2

I am filtering product collection like below. $productSkuString = 'O, C, D, A, F, S'; $productSkus = explode(', ', $productSkuString); $collection = $this->collectionFactory-&...
user avatar
  • 1,729
0 votes
1 answer
151 views

Magento 1.9 addAttributeToFilter() returning 0 products

I have the following code where i want product collection filtered with custom attribute. typeid = $data['categoryId']; $pagesize = $data['limit']; $pageno = $data['page']; Mage::app()-&...
user avatar
19 votes
3 answers
47k views

Multi Conditionals (OR and AND inside AND) in addAttributeToFilter

How to create a multi-condition in addAttributeToFilter? I want result in a SQL query like this (image attached) : WHERE ((`e`.`news_from_date` > '2013-09-12') OR (`e`.`news_to_date` < '2013-...
user avatar