Questions tagged [product-collection]

Questions related to Magento product collections.

Filter by
Sorted by
Tagged with
0
votes
0answers
5 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
5 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
9 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
18 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
94 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 ...
1
vote
1answer
40 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
27 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
24 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
5 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
30 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
19 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
22 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
23 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
48 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
17 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
29 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
50 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
146 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
12 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
367 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
12 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
16 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
98 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
78 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
56 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
28 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
26 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
19 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
153 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
51 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
23 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
32 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\...
0
votes
1answer
24 views

Magento 2: Display out of stock items in the end in API

I am using a headless magento 2 approach for my store. I have made an API which accepts parameters like: category_slug, sort_by, sort_order, page_size, current_page and returns the products ...
0
votes
0answers
40 views

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e.attribute_set_id'

I am trying to Filter the products based on vendorid with attribute_set_id. if i use print_r in the collection i am getting the result like below $objectManager = \Magento\Framework\App\...
0
votes
0answers
89 views

Issue with flat catalog table product collection in Magento 1.9

I am facing an issue regarding magento product collection as I have some additional product attribute and use general way to get product collection like: Mage::getModel('catalog/product')->...
0
votes
1answer
25 views

List all Products and change price, quantity and one custom attribute

We're a very small store and have to sell some of our products online. Magento is our system of choice. Right now we're still using Magento 1. For our shop we have the possibility to list all products ...
0
votes
1answer
206 views

Magento2: Error: Call to undefined method addViewsCount()

I have got the error below: Error: Call to undefined method Magento\Catalog\Model\ResourceModel\Product\Collection\Interceptor::addViewsCount() <?php namespace Vendor\Mostviewed\Block; class ...
1
vote
1answer
65 views

Magento 2 setCollection in phtml?

In Magento 1.9, If I want to call another phtml file in currenct phtml, I could use something as below. /** @var Mage_Catalog_Block_Product_List $productsBlock */ $...
0
votes
1answer
28 views

Magento 2 Product collection AddAttributeToFilter with AND/OR and !findinset and is null

How can i add " AND (at_product_userclass.value IS NULL) OR !FIND_IN_SET('1', at_product_userclass.value)" filter condition using addAttributeToFilter in product collection. Thanks
0
votes
0answers
17 views

Magento 2 - Collection Object filtered conditions values

I have filtred magento 2 product collection by different condition. Now , i need values of that options by which i have had filtered that collection. Any help appreciated. Urgent
0
votes
0answers
38 views

filter product follow condition magento 2

public function getLoadedProductCollection() { $this->_limit = (int) $this->getWidgetCfg('limit'); $type = $this->getTypeFilter(); $fn = 'get' . ...