Questions tagged [product-collection]

Questions related to Magento product collections.

Filter by
Sorted by
Tagged with
0
votes
0answers
10 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
10 views

Search / Filters - How is Magento doing it returning grouped/configurable/options 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. ...
15
votes
4answers
6k views

Magento 2 - Render custom product collection via list.phtml

The product grid of a category page (frontend) is rendered via layout in catalog_category_view.xml. Lets say I have a custom product collection (which I got via ProductRepositoryInterface::getList(...
0
votes
0answers
9 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
19 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
13 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.
2
votes
1answer
594 views

Magento 2 : collection filter error : Exception #0 (RuntimeException): Illegal state

I am having problem with collection filter I am using event catalog_product_collection_apply_limitations_after to add collection limitations In the observer i am using below code to apply filter. ...
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
4answers
4k 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 , ...
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\...
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 ...
3
votes
1answer
97 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 ...
1
vote
2answers
1k 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\...
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 ...
2
votes
3answers
2k 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 ...
1
vote
1answer
646 views

Custom Product Collection Filter

I created a custom form that search for specific product attribute my form look like this $location = $this->getRequest()->getParam('location'); $specialization = $this->getRequest()->...
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 ...
0
votes
1answer
735 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> <...
0
votes
0answers
25 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 ...
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 ...
1
vote
0answers
364 views

Magento-2 How to exclude category products from catalog search results

I need to change catalog search product results collection, exclude some categories from catalog search results. Anyone know how to apply category filters in search results. Thanks
0
votes
0answers
7 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
32 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
1answer
703 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 ...
3
votes
4answers
38k views

Magento 2: Product collection with filters

Can anyone tell me how can i get product collection with filters? I'm use magento 2 sample data now. So i'm trying to get in product collection like selected on picture with attribure style=backpack ...
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
23 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.
3
votes
3answers
395 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 "...
1
vote
1answer
877 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
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::...
2
votes
1answer
642 views

Upsell Products not visible if it's category and products category are different

Hi i'm having below categories Camera - DSLR - Digital Camers Accessories - Lenses - Memory cards I've added a product from lenses category as a upsell to a product from Digital cameras. but it'...
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
64 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 ...
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
1answer
657 views

Product get Small image from collection

i have tried a lot to get only small image from product collection of product object to create custom XML feed for my products. but could not able to get succeed yet. $imgname = Mage::helper('...
1
vote
1answer
912 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 ...
0
votes
0answers
18 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 ...
1
vote
1answer
732 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 ...
12
votes
1answer
885 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 ?
0
votes
1answer
30 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
52 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 ...
8
votes
3answers
8k views

Get product collection with product ids

Is it possible to get a product collection bassd on array of product ids?
3
votes
1answer
155 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 ...
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 ...
0
votes
0answers
13 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 ...
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.