0

I am trying to get results of products by stock quantity filter

i use this inside the constructor of my helper class.

 \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $product_lib

The question is how do i add stock quantity from and to in this?

$this->product_lib->create()->addAttributeToSelect('*')->
addCategoriesFilter(array('in' => array(1,2,3))->
addFieldToFilter('price', ['from' => $min_price, 'to' => $max_price])
->load();

When i try to additional addFieldToFilter with quantity it says not found. What i am looking for is to achieve the same results as in catalog->products filter.

Any suggestion is helpful. Also if possible can you suggest where to do i look for these kinds of information? Is there any book that would be helpful?

2
  • you means product filter using in stock quantity??? If yes check this link ---magento.stackexchange.com/questions/215617/… May 23, 2020 at 12:05
  • Thank you for answer. I want to get all products where stock_quantity >= $min_quantity and stock_quantity <= $max_quantity. But the above link seems to check if product is in status or not. May 23, 2020 at 12:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.