Questions tagged [product-collection]

Questions related to Magento product collections.

Filter by
Sorted by
Tagged with
0
votes
0answers
6 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
10 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
11 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
12 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
26 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
20 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
10 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
14 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
18 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
21 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
11 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
26 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
10 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
24 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
37 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 ...
0
votes
0answers
20 views

Magento 2 - Filter product collection by category just like layered navigation category filter

All I want to implement a category filter in the same way as Magento 2 layered navigation category filter does. I am filtering the product collection with the category ids that are getting selected ...
1
vote
0answers
55 views

Magento 2: How to get related product custom option using graphQl?

I want to get related products with custom option data using GraphQl. I am using the below GraphQl query to get related product custom options data. can anyone help with this? { products(filter: {...
0
votes
0answers
21 views

Sort products in category view - Magento 1.9

I want to always sort products in the catalog category view by is_saleable attribute. Firstly should show saleable products, later not saleable. I tried add $this->getSelect()->order("...
0
votes
2answers
33 views

magento 2 unable to get product Ids in foreach loop

I am trying to get all product ids of multi-select attribute "filter_type" ids($optionData) are assigned. But I am unable to get them as its only works first time. In second and other loop I am not ...
0
votes
0answers
35 views

Magento 2 collection not working on list.phtml

I want to display product on listing page attribute options wise. For e.g. filter_type attribute has multiple multi select options like: 1=> Specials 2=> Entree 3=> Breakfast Now I ...
0
votes
2answers
136 views

Get all visible products whose Quantity greater than 0 in Magento2

I have written a product collection to get all products whose quantity is greater than 0. Here is my code for the collection <?php $websiteId = $this->storeManager->getStore()->...
0
votes
0answers
34 views

Most view product collection with Filter Magento 2.3.3

Here, product_type is my custom product attribute. This is custom script for getting most view product collection and working well <?php use Magento\Framework\App\Bootstrap; require ...
0
votes
0answers
17 views

Magento 2 joinField custom $bind?

Summary I joined a field with the joinField function like this: $_productCollection->joinField('qty_new', 'cataloginventory_stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', '...
1
vote
2answers
321 views

Magento2.3 - get product collection in stock only

Magento 2 get product collection with filter stock get only in stock product in the collection See below code $collection = $this->_productCollectionFactory->create(); $collection->...
0
votes
0answers
82 views

Slick slider with ajax not appending in slider

I am trying to follow this answer but for me its not working perfectly I created custom phtml & block which will show the product slick slider, till time is working perfectly, but after the use ...
0
votes
0answers
19 views

Join stock to product list collection

How and where i can join stock information (Qty) to product collection in product list. In catalog layer or somewere else? I try to <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
3
votes
8answers
217 views

Magento2: I want to show featured product on top of the category and search result

I have yes/no type product attribute. If this featured attribute is yes for any products, those product will show top(first featured product showing in category page then rest of the products are ...
0
votes
0answers
19 views

Search / Filters - returning grouped/configurable/options results when their children match?

I am trying to understand why in the core Magento functionality search and layered navigation are fine returning parent products when children are a match, but why so many extensions fail to do so. ...
0
votes
0answers
28 views

Magento 2: Add extension attributes to product collection

I have added extension attribute to Magento\Catalog\Api\Data\ProductInterface using extension_attrributes.xml and its getting reflected when I get product(s) using ProductRepository's get, getList and ...
0
votes
0answers
10 views

Filter Layer Collection

I rewrite getProductCollection in /vendor/magento/module-catalog/Model/Layer/Search.php. How could i filter collection there. In filter i need remove all products with attributeSetId = $id &&...
0
votes
0answers
18 views

Magento2: How to create custom module category page with filter?

I have category listing page and I want to display product on same page. I want to display same layout like category page with filter. Please help.
0
votes
0answers
23 views

Multiselect filter

We have an attribute which is multiselect ( most products have single value and some multiple) .. now customer wants to add filter where this attribute should be lower than a given value. is there a ...
3
votes
1answer
154 views

How to get in stock product collection by category id in Magento 2.3.3?

I'm using Magento 2.3.3 with multiple websites store that uses different multiple stock sources(multi inventory) and I tried to retrieve product collection by category id like this: public function ...
0
votes
0answers
20 views

How to get product collection in custom admin form by entering SKU, Name or ID in input field in Mageno 1?

I had created a custom admin form and added an input search field for Product search. When I add a specific product detail, i.e. product sku or product name or product id. I need to fetch the product ...
1
vote
1answer
78 views

How to get Product id from specific Product Catalog Rule?

I created a widget which is a display product section for a specific catalog price rule selected by admin. Ex: Admin select 20% off on pants from backend & '10' will be limit of displaying ...
1
vote
1answer
40 views

Magento2: What is difference between ProductFactory and CollectionFactory?

What is the difference between this below code? Class : \Magento\Catalog\Model\ProductFactory Code : $this->productFactory->create()->getCollection(); Class : \Magento\Catalog\...
0
votes
0answers
31 views

Magento2.3.3: Custom Widget return null in Block file

I try to create a custom widget List of comma-separated product ids to be displayed on the front-end.getting id's from widget and use in block But in block it return null value. how can I get these ...
0
votes
0answers
14 views

Magento2 collection filter two different values for same attribute as AND search instead of OR

I have some multi-select product attributes that need to be filtered with an AND instead of OR. In other words a product needs to have an entry for an attribute for the first marked value AND the ...
1
vote
2answers
109 views

Get products collection by store id in magento2

How get product collection by store id I tried below code $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productCollection = $objectManager->create('Magento\Catalog\Model\...
1
vote
0answers
21 views

Magento 2 collection filter need advies

We have grouped products - rims. Now we want to sell it with tires. Logical is to look up for needed tires and show them, although the problem is if we do that we get results for front and back. but ...
1
vote
0answers
29 views

Magento 2 : Frontend load ajax page custom product collection with search set total items

Facing issue with frontend load ajax page custom product collection with search set total items 1 in Magento 2.
0
votes
0answers
10 views

Filtering product collection with 2 non flat attributes?

I got 2 attributes which are not in the flat product table. So I am trying to join the 2 attributes into my collection. I got it working for one of the 2 attributes, like this: $collection = Mage::...
0
votes
0answers
26 views

Display product collection without limit in Magento 1

I created a custom module that redirects your homepage to a landing page (CMS Page) that is a campaign page, for example, black friday. I've created a new layout for the page, layout that uses a ...
0
votes
1answer
172 views

Magento 2.3: How to filter product collection by stock status

Having trouble figuring out how to filter a product collection by in stock / out of stock status. My goal is to get all out of stock products that also match some other filters: public function ...
0
votes
0answers
23 views

magento 2 sort using ORDER BY FIELD

Case : i have create attribute name : Populairty attribute details as below , i have set Used for Sorting in Product Listing as yes , value of it can be as 1: yes 2: no 3: very popular i want to ...
0
votes
0answers
25 views

Special Products Collection

I've been trying to get a special price collection of products for Magento 2 but I keep on failing. I've got the following example that works(almost): protected function ...
0
votes
0answers
14 views

Do I need to loop all children of the configurable product to know the stock of each product size?

In a shoe store I have the following configuration: For each color we have a configurable product, and in this configurable product we have size variations. We have a size filter ... when a customer ...
0
votes
1answer
39 views

magento getProductCollection add random order and exclude a product id only from output

I want to get random product from category id which is working find but i want to exclude a particluar product id from out and show output in random order Below is my code , please help me with way ...
0
votes
4answers
111 views

How to filter product by specific attribute in Magento 2?

I want to filter a collection of products by product (brand) attribute, thanks
0
votes
0answers
14 views

product collection result overriding by other module

I have two 3rd party modules one groupCat module which filters out the product collection to display customers based on customer groups. another module is the search module which fetches all products ...

1
2 3 4 5
14