Timeline for Magento 2 Get product collection in a custom template block
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 12, 2016 at 14:32 | comment | added | Alex Paliarush |
@mrtuvn $this->_searchCriteria should contain necessary filters. addAttributeToFilter is defined for collections and is not available for repositories. Take a look at these answers
|
|
Jan 12, 2016 at 10:36 | comment | added | mrtuvn | @AlexPaliarush How do i use filter by attribute and select attribute like name, id, v.v.. via ProductRepository example:$this->_productRepository->getList($this->_searchCriteria)->addAttributeToFilter('is_featured', 1) results undefined method trigger | |
Dec 1, 2015 at 13:13 | vote | accept | CommunityBot | ||
Dec 1, 2015 at 13:13 | comment | added | Vicky Dev | Thanks, your solution is working perfectly for now. Accepting it. | |
Dec 1, 2015 at 13:07 | comment | added | Alex Paliarush |
$productCollection->addCategoriesFilter(['in' => [1, 2, 3]]) should work.
|
|
Dec 1, 2015 at 12:27 | comment | added | Vicky Dev |
Thanks for reply, can you tell me how to filter this collection by category_id , I tried filtering using function addFieldToFilter but it gives error, I guess addField.... function only works for table's own fields not with joining tables.
|
|
Dec 1, 2015 at 11:48 | history | answered | Alex Paliarush | CC BY-SA 3.0 |