Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    Product Collection by categories magento2

    Here we are discussing how to get the collection of products assigned to any categories.

    To get product collection you can use following code:

    Here, $categories is an array, which include category ids.

    $_productCollectionFactory is an object of product collection factory which is used to get collection of product model.

    addCategoriesFilter function to apply category filter.

    $collection returns a collection of products which are assigned in given categories.

    Thank you.

    . . .

    Comments (2)

    Add Your Comment

  • jafar
    how to get most selling product from category
  • Navin Bhudiya
    How to apply AND condition
    Let me explain in details.
    i want product that have 1,2,3 Categories mens , list of all product with same category. above code not work for this logic
  • Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again