Questions tagged [product-collection]

Questions related to Magento product collections.

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

magento 2 hide out of stock products except when a specific attribute equals yes

I would like to hide out of stock products generally so I've added the option in the store configuration settings. However there are certain products that will be restocked soon. I'd like to keep ...
0
votes
1answer
12 views

Magento 2 : Trying to Override ListProduct.php Block File for Custom Product Collection

I am trying to override ListProduct.php Block File Using Preference method But InitialiseProductCollection() being a protected function does not give me result. I need to know how can I override a ...
0
votes
1answer
29 views

Unique Products in Product Collection Filtered with Category Array in Magento 1.9

I have tried below 3 method but it is not giving correct products as per cateory id array. First Way $_productCollection = Mage::getResourceModel('catalog/product_collection') ->...
0
votes
0answers
10 views

How to get the best selling products in a category and sort them from best selling to least selling?

How to get the best selling products in a category and sort them from best selling to least selling? I try get best selling collection like: use Magento\Store\Model\StoreManagerInterface; use Magento\...
0
votes
0answers
10 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 ...
2
votes
0answers
76 views

Magento2 filter products based on location (custom attribute) programmatically

I have a Magento2 Store (v2.4) where I have multiple locations. for (eg. Jaipur, Delhi, Mumbai etc). I have managed locations using custom attribute using multiple dropdown list and assigned it to ...
0
votes
0answers
14 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
28 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([$...
0
votes
0answers
14 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
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
42 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:/...
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
28 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
7 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
40 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
8 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'); ...
0
votes
1answer
48 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
13 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 ...
0
votes
1answer
59 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 $...
0
votes
1answer
45 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
0answers
41 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\...
0
votes
0answers
163 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
61 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() ...
1
vote
1answer
79 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 ...
1
vote
0answers
25 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
2
votes
3answers
262 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, ...
3
votes
1answer
251 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 ...
0
votes
1answer
30 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 ...
1
vote
1answer
120 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
107 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\...
0
votes
1answer
131 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
64 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: ...
0
votes
0answers
127 views

Magento 2 - How to use mysql find_in_set?

In Magento 2, I try to use find_in_set mysql function but without success. I try this : $result->getSelect()->order("find_in_set(e.entity_id,'".implode(',',$sort_order)."')"); But it give me ...
0
votes
0answers
28 views

Magento 2: How to override product collection in Category page?

I want to add load a custom product collection into a specific category page in Magento 2 instead of rendering default category page product collection ? is this possible? how to do this?
1
vote
1answer
22 views

Out of stock products: why do they appear in Collection::getAllIds and not in Collection::getItems

Im trying to get all products in a collection: out of stock and products in stock. So what I did is: /** @var $collection \Magentp\Catalog\Model\ResourceModel\Product\Collection */ $collection = $...
0
votes
0answers
19 views

Product Collection incorrect no of products count after applying filters

I have extended ListProduct class into my custom module like this: di.xml <preference type="Ktpl\QuickShop\Block\Product\ListProduct" for="Magento\Catalog\Block\Product\ListProduct"/> ...
0
votes
1answer
13 views

Can't find category_ids in of each product in product collection

How can we include category_ids in product collection getData? Join field didn't work for me. For example, look at the below code Mage::getModel('catalog/product')->getCollection() -&...
0
votes
0answers
19 views

How to filter products by “ Set Product as New From To” datepicker ? Magento 2

I need to filter product collections by " Set Product as New From-To" (attached), can anyone helps me ? Thanks
1
vote
1answer
28 views

For each Loop Not Print Proper Data

On product listing page I have $_productCollection = $block->getLoadedProductCollection(); if I call getData on $_productCollection I get different array than I get in foreach loop. Does anyone ...
0
votes
0answers
102 views

Get order Collection of last 14 days based on product collection

I have already product collection which fetches product based on category id, now I want to fetch only products which are ordered from last 14 days from above condition Any SOlution? public function ...
0
votes
0answers
49 views

Magento 2: Sort Product collection by updated Special Price

I want to sort product collection by updated Special Price. When I update the special price of any product, that product should come first in my collection. How to sort this collection:- $count ...
0
votes
0answers
19 views

Block collection and script giving different result in magento 1.14.2.2

I am trying to get latest product collection, it is working fine and giving correct result with root script but when I try code in block class it is giving me wrong ids Script code: <?php //...
0
votes
1answer
40 views

Magento 2.3.2 sort collection by stock availability

I want every collection with 0 stock to get moved to the bottom (last position) I've tried using a plugin. My di.xml <type name="Magento\Catalog\Model\Layer"> <plugin name="...
1
vote
1answer
210 views

Magento 2: Filter Product Collection using Category Id always return empty set

I have a parent category with subcateogry that contains a lot of product in it, when i tried to filter the product collection using this parent category id, it always return an empty collection: ...
0
votes
0answers
24 views

Magento 2 Get product collection that has final price that lower then original price

I'm using Magento 2.3.4 , and tried to load a product collection that has original price higher then final price like this: $collection = $this->productCollection->create()->...
0
votes
0answers
72 views

Wrong store_id in product collection

I need to cycle products collection for each store. But the method $collection->addStoreFilter($store) seems to not work properly. I also tried to $collection->setStore and setStoreId. The problem ...
0
votes
0answers
38 views

Clone collection magento 1.9

I need to get total count as per filter conditions then need to put the pagination settings on collection. Here is my code: <?php public function getCustomizedProducts($manufact,$page,$...
0
votes
0answers
211 views

REST API Get products info based on name Magento 1.9

I have created a custom module but unable to get products based on categories name, If I pass a single name it is working. app/etc/modules/Custom_Restapi.xml <?xml version="1.0"?> <config&...
0
votes
1answer
56 views

data patch changes does not affect database

I have created Data Patch, debugged it and everything works as expected, products are removed from the collection but after running setup upgrade changes are not made in the database, what can be ...

1
2 3 4 5
14