Guest User

Untitled

a guest
Oct 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. $queryName = 'bat';
  2. $category = $this->_categoryFactory->create()->load('2');
  3. $collection = $this->_productCollectionFactory->create();
  4. $collection->addAttributeToSelect('*');
  5. $collection->addCategoryFilter($category);
  6. $collection->addAttributeToFilter(['name', 'sku'],
  7. [
  8. ['like' => '%'.$queryName.'%'],
  9. ['like' => '%'.$queryName.'%']
  10. ]);
  11. $collection->setPage(1,15)->load();
  12. return $collection;
  13.  
  14. $collection->addAttributeToFilter(
  15. [
  16. ['attribute' => 'name', 'like' => '%'.$queryName.'%'],
  17. ['attribute' => 'sku', 'like' => '%'.$queryName.'%']
  18. ]);
Add Comment
Please, Sign In to add comment