Questions tagged [product-collection]

Questions related to Magento product collections.

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

can i use one product collection for multiple attribute filtering?

I have a product collection based on category. Can I use addFieldToFilter (color) for both equal and not equal. Color with given value as one set of collection and color which is not equal to given ...
1
vote
2answers
990 views

How to get related product collection in block

I use this way to get related product collection /** * Prepare and return product collection * * @return \Magento\Catalog\Model\ResourceModel\Product\Collection */ public function ...
0
votes
1answer
103 views

Magento 2: How to get search products Collection

I need to get search products collection in .phtml. Currently i'm getting but Bundle products are missing. I want custom search collection. Thanks in advance.
0
votes
0answers
12 views

Magento2 custom product collection not filtering via color etc.. on listing page

Magento2 custom product collection not filtering via color etc.. on listing page Following is the code used public function getClearProductCollection() { $categoryId = $this->...
1
vote
1answer
946 views

How to get all products collection for special category

I am looking for function which is similar to getLoadedProductCollection and which retrieves all products from this category with selected filters, not only those I can see on current page like ...
1
vote
1answer
26 views

Adding category filter to loaded product collection?

Magento 2.3.3 This is my code: $_productCollection = $block->getLoadedProductCollection(); $values = [66]; $conditionType = "in"; $_productCollection->addCategoriesFilter([$...
1
vote
1answer
1k views

How to filter related product collection by is_salable magento 2?

Related products are showing with out of stock products, I want to hide out of stock products from related products only. $this->_itemCollection = $product->getRelatedProductCollection() -&...
0
votes
0answers
10 views

How to add criteria to all product search?

I associate all my products to at least 1 category (visible from menu) + 1 'special' category (not visible from menu). There are many 'special' categories, they are special because not visible form ...
0
votes
2answers
1k views
0
votes
0answers
12 views

can't display the product's name after addAttributeToSelect

I have a table and this table will display the product's name, image, sku, category,and stock. when I use $products = $this->_productCollectionFactory->create()->addAttributeToSelect('*')->...
0
votes
1answer
39 views

Magento2: filter product collection by custom attribute

I am using Magento ver. 2.3.6. I want to filter product collection by custom product attribute and I am using below code:- di.xml <?xml version="1.0"?> <config xmlns:xsi="http:/...
12
votes
1answer
946 views

Magento2 Custom Layered Navigation

I want to add a layered navigation block for a custom product collection. Is there a way to do that in Magento2 ?
3
votes
2answers
17k views

Product collection filter by stores

How do I filter a product collection so that it includes only products in store 2 that are not in store 3. It can include any other stores as long it is in store 2 but not in store 3. product->...
0
votes
0answers
9 views

Add FIlter to Grid under category section products in category tab

I am using Magento 2.3.4 EE. Anyone have any idea how can I add a filter under category section and 'products in category' tab admin. If you guys have any Idea please share. Any help will be ...
0
votes
2answers
26 views

How to show related products Magento 2.3.5

I want to show related products on product page only from my custom module. I am not sure if I can or is it possible to do it. I am doing a check by if my attribute is enable I will change the outcome ...
0
votes
0answers
6 views

Archives for custom product collection

I'm trying to create an archive ( like search results page) containing specific products. As an example let's say we prepare a collection of products using a form as the input. With the submit of the ...
0
votes
0answers
38 views

Using foreach change the position of my product collection

The best way to explain this issue is showing an example: In the product list.phtml I had the following <?php $logger->info($_productCollection->getData()); foreach ($...
0
votes
0answers
6 views

I need to get product collection by filter multiple category ids and attributes in magento 2

I need to get product collection by filter multiple category ids and attributes i tried below ways $prodColl = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection'); ...
3
votes
4answers
5k views

Get all product information

How to display all Product Information in particular Attribute set like Product name , sku , attributes etc.. It shows Attribute Name & Id but i want all details like Product name , sku , ...
4
votes
3answers
2k views

Add Filter to magento 2 category product collection

a similar problem. If i want filter product collection, create plugin for Layer (if use event the result will be the same). The collection is correct and show only 2 products. But the Pagination ...
1
vote
2answers
2k views

Magento 2: addAttributeToFilter not returning any results

When I use addAttributeToFilter on Magento\Catalog\Model\ResourceModel\Product\CollectionFactory, with a custom attribute, I always get 0 results. use Magento\Catalog\Model\ResourceModel\Product\...
2
votes
1answer
1k views

Show all products on one page in Magento 2

I need a page where all products should be displayed. All products from all categories, also including filters by attributes. I have tried to use the following block {{block type="catalog/...
0
votes
1answer
795 views

Magento products collection change reload category page

I am tring to change product collection using catalog_product_collection_load_before. I need to sort products by in stock. Out of stock must be last. following config.xml, <events> <...
13
votes
2answers
27k views

Magento 2 How can we get product url with product collection?

I am able to load product collection by using [$objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection')] in my phtml file.But in that collection product url is not there ...
0
votes
1answer
44 views

Why my Disabled product collection gives empty array in magento 2?

I want to get disabled product id's in my system but it gives me an empty array. Here is screenshot of my products.When i grab disabled product by using this code $updatedproids = []; $...
0
votes
0answers
8 views

Layered navigation for custom collection on custom page - magento2.3.5p1

I Have a custom collection Listing page. I need to add Layered Navigation on it. I have Override Listpage.php block and I get the collection in it. I follow two blogs but they get the collection ...
1
vote
2answers
747 views

Get All Items including Disabled Products in Product Collection

I want to get all products including disabled and enabled in one of my static page. I am fetching product collection like $videoProduct = Mage::getModel('catalog/product')->getCollection() -&...
0
votes
1answer
57 views

Unable to get not visible products after applying category filter magento2

I am trying to get Child products from collection after applying category filter but unable to get all products (want to get all products including Not Visible Individually products $...
1
vote
1answer
1k views

Include Toolbar Pager in custom product collection in custom page

I have a custom page where I am listing the custom product collection. I am using the default catalog/product/list.phtml as template to display the page. It's listing fine like the category page. But ...
0
votes
1answer
44 views

How to use orderCollectionFactory and productCollectionFactory together in Model file?

I have created a custom attribute in product and saved a string in that value and I want if some one order those product of same value string i want that collection of product. So, i want to use \...
1
vote
1answer
826 views

Magento 2.1 : Pagination of product collection

I am working on a custom script (not custom module) where I need to fetch product collection and display 5 products at a time. After displaying 5 products there is a link Next which displays next 5 ...
1
vote
0answers
32 views

Get compare product collection on CMS, Catalog Pages

I have used the below code but that is not working on catalog, cms & product page for me. but for compare page, cart page, and checkout page it's working. $objectManager = \Magento\Framework\...
2
votes
4answers
4k views

How to get recently viewed products collection of Customer Magento 2?

Magento 2 get recently viewed products collection of Customer (Using customer ID) programmatically I tried this solution But I want recently viewed products collection. I tried below solution too ...
0
votes
0answers
45 views

How to get Salable Quantity in product collection?

Need to filter product collection by salable qty in frontend in catalog>product>list.phtml. Currently, I am processing the saleable qty inside foreach loop but it takes lot of resources and some ...
0
votes
0answers
10 views

I have bundle product and got its id I want to get the bundle option for that product

I want to get collection of bundle option_id from table "catalog_product_bundle_option" related to the parent_id which I have passed
2
votes
0answers
41 views

How to cache a product collection in Magento 2?

Currently i load a product collection under certain categories, for example: $collection->addCategoriesFilter(array('in' => array('2','4'))); $collection ->addMinimalPrice() ...
2
votes
3answers
170 views

How to get product collection with different page sizes?

I need to get 29 products on page #1 and need to get 26 products from page #2 to the last page number without duplication. I'm setting page size as 29 in the first page and 26 from the second page, ...
4
votes
6answers
17k views

Magento2 - product collection filter out of stock products

I could not find any relevant reference how to filter out products that are "Out of Stock" when dealing with product collection. Here is the code sample: <?php $collection = $this->...
1
vote
1answer
56 views

Magento 2: Product collection filter with custom attributes with like

I am using magento 2.3.3 i have custom module in that i am using search when any one search i am filter products name like it is working fine but now i want add extra attributes.I have created product ...
0
votes
2answers
1k views

Fatal error: Uncaught Error: Call to a member function setProductCollection() on boolean in

( ! ) Fatal error: Uncaught Error: Call to a member function setProductCollection() on boolean in /var/www/html/magento2/ShopQuary/app/code/MagentoCoders/Manufacturer/Controller/Index/Index.php on ...
2
votes
1answer
148 views

Filter Magento2 Fulltext\Collection by OR condition

How can i filter the Magento2 Fulltext\Collection (Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection) by an OR condition between 2 product attributes, with respecting also the ...
1
vote
0answers
24 views

How to get product id's of first page in the second page in magento 2 plp

I need to get first page product id's while calling second page collection in ListProduct.php
0
votes
1answer
27 views

Can i add product in category page product collection?

Can I add a product in category page product collection? I want to add product #123 in category page product collection but the same product already exists in the collection so it is possible? My ...
2
votes
3answers
8k views

Magento 2 How to get product collection of all products?

I am trying to fetch the product collection in Magento 2 which return the all products including -> with all instock and out of stock products -> with all Visibility (Not Visible Individually,...
1
vote
1answer
750 views

Catalog: Custom Product Collection, mode switch (grid/list) bug?

Edit: I think I found a solution. (See answer by me below) I have a product collection which I pass to the Magento catalog/product_list block. I've set curPage and pageSize of the collection and ...
1
vote
1answer
69 views

Magento 2.3 product collection->getData get correct answer but foreach or load() not

Same with here : Magento 1: $productCollection->getData() vs foreach ($productCollection as $product), want add more information. Create new product then $productCollection = $objectManager->get(...
0
votes
1answer
56 views

How to join a custom table and show its attribute on Magento 2 rest Api getList() function?

Im creating a custom product Api with searchCriteria from \Magento\Catalog\Model\ResourceModel\Product\Collection And I joined other table to this collection; public function getList(\Magento\...
4
votes
2answers
535 views

Show previous and next link in link tags under head in category page

In category page, I need to show link tags that holds pagination's previous and next links like below: <link rel="prev" href="http://www.test.com/prod1.html?p=1" /> <link rel="next" href="...
0
votes
1answer
73 views

Pagination in Custom Collection magento 2

I am retrieving data from third party as an object, I am forcefully converting an object into array and collection. I want to apply pagination with the data, I tried using core pagination logic and ...
0
votes
0answers
37 views

Magento 2: load product collection of another website

Magento 2.2.9: I have a multiwebsite-setup. Site 1 is a normal webshop. Site 2 is a satellite page that links to site 1. So I would like to create a product collection from site 1 starting like this: ...

1
2 3 4 5
14