Questions tagged [product-collection]

Questions related to Magento product collections.

Filter by
Sorted by
Tagged with
0
votes
2answers
62 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
28 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
18 views

How to get product collection of products that has special price filtred by specific category id

I'm trying to get product collection of all products that has special_price and their special_to_date is less than today's date, and they belong to a specific category. I tried the bellow code but it ...
0
votes
0answers
13 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
92 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->...
1
vote
0answers
28 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
18 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
189 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
18 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
21 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
14 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
22 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
112 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
18 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 ...
2
votes
1answer
48 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
29 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
27 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
8 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
40 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
20 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
24 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
9 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
25 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
85 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
20 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
24 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
12 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
34 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
87 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 ...
2
votes
2answers
53 views

Magento 2.3.2 Collection foreach didn't get disabled product

I am using Magento 2.3.2. I am filtering collection if product ids found in array. before foreach if I am printing collection I am getting data. But in foreach I am not getting any data. $productIds ...
2
votes
0answers
24 views

Get all associated categories from product collection

For a custom filter on the product collection i need to be able to get all associated categories from all products from the catalog search result. On top of that, i do not need the actual categories ...
3
votes
1answer
174 views

Magento2 - catalog product listing collection sort by price with dynamic price calculation

product price is calculated dynamically based on certain conditions. while sorting with price it takes only default price not dynamically calculated price. the same issue with the price filter. I can ...
0
votes
0answers
17 views

Magento 2 Custom module export via cron no products

I created a custom module that at regular intervals creates an XML file with selected product data. The process that generates the XML can also be run from Magento CLI via a custom command. Although ...
3
votes
3answers
476 views

Magento 2.3.3 addAttributeToFilter is_saleable attribute no longer supported

After upgrading to Magento 2.3.3 product collections filtering with the is_saleable attribute no longer appears to work and the following error is seen in templates calling the collection : The "...
0
votes
0answers
13 views

Show out of stock products with layered navigation in magento 2.3.1

How to show out of stock products with layered navigation for one category if Display Out Of Stock is disabled in the admin? I tried many ways but I could not find the solution, please help.
0
votes
0answers
12 views

Magento 2.2 Custom Product collection for layered navigation

I changed the product collection for product list page but can not able to change product collection for layered navigation. Where to change custom product collection for Layered Navigation??
0
votes
0answers
17 views

Magento 2.3 - Layer navigation with custom product collection not working

I have created a preference to add my custom filter to the collection. di.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:...
0
votes
3answers
173 views

How to get product collection in controller in Magento2

I am creating a new module in magento2 and in controller file, I try to get product collection in controller index.php file so how can I get product collection in Magento 2. so give me suggestion to ...
0
votes
2answers
152 views

Magento 2: Sort Product Collection by date added to category

From a category page, I grab the product collection from the category object like so $productCollection = $category->getProductCollection()->addAttributeToSelect('*'); However, the results are ...
0
votes
2answers
64 views

Why product collection model don't show real Sql query?

I want to understand how M2 loads products EAV attributes, so I wrote the following code: $productCollection = $this->productCollection->addFilter('entity_id', 7) ->...
0
votes
0answers
29 views

Magento2 - hide special price products

I would like to hide any products with a 'special price' from the main catalogue to only show them on a custom 'sale' page. I could probably do this in M1 but I do not know what the general approach ...
0
votes
3answers
27 views

Magento 2 addAttributeToFilter not adding to SQL

I'm trying to get a list of products with a custom attribute set a certain way. Right now only one product should be returned, however it's returning the whole catalog. It seems like my added ...
1
vote
0answers
22 views

Join attribute lable in product collection

I'm creating one grid which will have to below columns like SKU,Name and Color (Attribute) So to achieve this We've to join color data to collection for that I've added _initSelect to collection ...
0
votes
1answer
193 views

Magento 2 Custom Product Collection Size Problem after Removing Products from Collection

In Category list view I want to create a custom collection where some products are not shown OR the entire collection is re-sorted. To test this I created an observer for the event ...
0
votes
0answers
58 views

Magento 2 _getProductCollection reset and set filters

I'm building module which will implement custom logic in to filter system. Right now i have rewrited Magento\CatalogSearch\Block\SearchResult\ListProduct: class ListProduct extends \Magento\Catalog\...
0
votes
0answers
26 views

Magento 2: Custom attribute not showing on custom productCollection

I have a Magento 2.3 helper module with a function to get a specific set of fields for a set of products, in basis this works fine. public function getSeriesCollection() { $product = $this->...
1
vote
2answers
80 views

Some added products in cross sells not visible in frontend Magento 2

I have added few products in cross-sells but some are visible and some are not visible in the UI(frontend). I referred to a Magento bug that only 2 items were visible in the backend https://github....
1
vote
2answers
34 views

Product collection retrieval N at a time (paginated)

I want to retrieve all the products. But would like to limit it to say 100 at a time to avoid too much memory usage. I have the collection factory injected in the constructor as \Magento\Catalog\...

1 2 3 4 5 14