Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
0 votes
1 answer
27 views

Magento 2 override product list page collection

I am trying to override the product collection of the product list page (category page). (Just for testing locally) I am editing the vendor/magento/module-catalog/Block/Product/ListProduct.php file ...
sulman's user avatar
  • 529
0 votes
0 answers
29 views

Magento 2: Add Product Attribute Filters on Magento 2 Custom Product Collection [duplicate]

I've a custom product collection displayed on a custom page. This part is working fine. Now I want to add the product attribute filter on that page to provide customers to filter the products based on ...
Sumit's user avatar
  • 4,875
0 votes
0 answers
12 views

Test class with collection and save

i'm trying to test if a class method is doing her job. Basically here it is. public function __construct(SaveCommand $saveCommand, SubscriptionData $entityDataFactory, ...
Claims's user avatar
  • 1,164
0 votes
1 answer
27 views

How to filter customer collection by custom field added by db_schema xml file to customer_entity table in Magento 2?

I added 'custom_field' to 'customer_entity' table by using 'db_schema.xml' file and need to save 'some value' in it then I wanted to filter the collection by 'custom_field' value. How can I achieve ...
shankar boss's user avatar
  • 1,453
0 votes
0 answers
26 views

List products including out of stock products in custom module (without listing out of stock products on the whole shop!)

I’m having a custom route in a custom module where I’d like to list a subset of products for a specific search criteria. I’d like to include here just for this action the out of stock products. BUT I ...
denis's user avatar
  • 101
0 votes
0 answers
10 views

Filter Product Grid Column Based on SQL calculation

I have a custom column within the Product Grid that states whether a product is In Stock or Out of Stock, based on whether or not the Salably Quantity is greater than zero. While I have managed to get ...
A. Andersen's user avatar
0 votes
0 answers
9 views

Group by on collection on Magento 1.7

In Magento 1.7, I added a column in the shipment grid displaying the total of the associated order for each shipment. To achieve this, in the Mage_Adminhtml_Block_Sales_Shipment_Grid file, I added the ...
Infocurci's user avatar
0 votes
1 answer
42 views

Argument 5 passed to Vendor\Module\Model\ResourceModel\PriceResult\Collection\Interceptor::__construct()

I have created a custom module and it's working fine,if I only run php bin/magento setup:upgrade command. However, when I attempt to run php bin/magento s:d:c it raises an exception. Type Error ...
Bushra's user avatar
  • 62
3 votes
0 answers
170 views

Update layer navigation filter with the proper custom collection

Goal : Create a /test/index/index route that will load a product listing page with a custom collection. Expectation : The custom collection printed in listing and the filters must be properly defined ...
Claims's user avatar
  • 1,164
0 votes
0 answers
18 views

Apply a custom collection to the layered navigation filter

By extending Magento\Catalog\Block\Product\ListProduct; and replacing in the layout by my custom block I have been able to apply and load a custom collection in any category. The issue is that the ...
Claims's user avatar
  • 1,164
0 votes
0 answers
27 views

Show Image Banner between the date

I am displaying my banner on the page, it is displaying correct. I want to show the Banner between the dates from the "display_from" to "display_to". I am getting my all date in ...
Rana Zain's user avatar
  • 662
0 votes
1 answer
458 views

How to load a custom product collection in frontend using smile elasticsuite

Everything is in the question i need to load a custom product collection in frontend using smile elasticsuite. But i can't figure out how to do it. Do you guys have a working example ? "smile/...
Claims's user avatar
  • 1,164
1 vote
1 answer
54 views

How to get product collection unmatch product ids with custom collection ids in magento 2?

I want to get the unmatched product ids of catalog products with a custom module collection product ids. For Example : The catalog product entity table has 12,14,15,16 product ids The custom table ...
Jitendra Patel's user avatar
0 votes
0 answers
59 views

Wrong pagination size after filtering category product collection with custom condition

I am trying to filter the category products collection on the basis of custom product attribute, i used many ways to override the collection but every method is filtering the records per page rather ...
Jasvir Singh's user avatar
0 votes
3 answers
497 views

How can I remove a condition from a collection

I tried to use two methods to reset or clear the collection but it didn't work. I am working with the category collection on which I want to remove this part of the condition : (e.created_in <= '...
Alok Tiwari's user avatar
0 votes
0 answers
14 views

Issue with getting custom review collection based on product entity ids array with limited records

I am using this class to get review collection. \Magento\Review\Model\ResourceModel\Review\CollectionFactory I am using following function to get reviews collection based on product entity ids and my ...
Vishal Rathod's user avatar
0 votes
0 answers
31 views

How to make a virtual category NOT visible in filters left bar

I have virtual categories with products in them to be able to display them as a productpage with products from the same series/collection. I don't want these categories to be visible in my filters in ...
Claire's user avatar
  • 1
0 votes
2 answers
343 views

Convert SQL Select Query to Magento Collection

I have a complex sql select query which actually returns sales report against specified categories. I want to load data as a collection to display but I'm not able to convert the query into Magento's ...
jack's user avatar
  • 1
0 votes
2 answers
1k views

magento 2.4 product collection filter by custom attribute value instead of id

Via backend, I added a dropdown custom attribute on my products. Now I need to filter the product collection based on the value of this dropdown. If I add the option id in the filter, everything ...
Lou Nik's user avatar
  • 443
0 votes
1 answer
194 views

Add limit on collection of custom table and get one column value in Magento 2

I know there are solutions for getting one column as an array. $collection->getColumnValues('column_name'); And adding limit without setPageSize() and setCurPage() $collection->getSelect()-&...
Knight017's user avatar
  • 632
0 votes
1 answer
24 views

Sorting by one field in the collection does not occur

I have a plugin for the afterSetCollection method, which is hung on the Magento\Catalog\Block\Product\ProductList\Toolbar -> setCollection method. But for some reason, sorting occurs by the price, ...
Edward Brown's user avatar
2 votes
0 answers
83 views

How to stop huge memory consumption when iterating over large amount of orders?

I created a console command to create invoices and shipments for a certain set of orders. The total amount of all affected orders is about 79000. When I execute the command memory consumption is going ...
Daniel's user avatar
  • 2,229
0 votes
1 answer
88 views

magento 2.4 preserve original collection after manipulation

As the title suggests, I'd like to call my collection, store it into different variables, then manipulate the variables but leaving the original collection intact. The code should be something like ...
Lou Nik's user avatar
  • 443
0 votes
1 answer
101 views

Product Collection Methods: addFieldToSelect() vs. addAttributeSelect()

What is the difference between ->addFieldToSelect('name') and ->addAttributeToSelect('name')?
A. Andersen's user avatar
0 votes
1 answer
28 views

Product collection filter by Downloadable Information

I want to get a product collection with fillers(Downloadable Information link, URL). My current code is below. $pcollection = $productCollection->addAttributeToSelect('*') ->addAttributeToFilter(...
SURENDER SINGH's user avatar
0 votes
1 answer
57 views

How to get only duplicates entries in collection?

I want to get only those rows having same sku two or more times in collection using magento2? how can i perform this in magento2 collection way
Syed Hassan Zamir's user avatar
2 votes
2 answers
392 views

what this means 'neq' in magento2

can someone explain for me the this attribute used in array? $order = $this->createObject(Order::class) ->getCollection() ->addFieldToFilter('...
Bayzel's user avatar
  • 187
2 votes
1 answer
1k views

Magento 2.4 create custom filter for products in listpage

I'm migrating Magento 2.3 to 2.4.5. Already I have a working feature of a custom attribute filter in the Product list page also having a plugin but the class Magento\CatalogSearch\Model\Search\...
Ramesh KR's user avatar
  • 866
2 votes
1 answer
213 views

Magento 2: Remove Duplicates From The Collection

I have a custom model with three fields, i.e id, city and region. How can I remove duplicates from the region column when querying the table? How can I group all the cities under the same region? I ...
Tebby's user avatar
  • 23
2 votes
1 answer
772 views

Magento 2 - Best way to query data from tables (select with multiple joins)

I'm learning about Collections, Repositories and DTO, and I'm still trying to figure out what's the best way to query a table to fetch data. I also found that we can use \Magento\Framework\App\...
Douglas Vicentini's user avatar
2 votes
1 answer
193 views

How to get new/refresh Collection?

I'm trying to get bestsellers collection, and set a period. I want to load diffrent period collection if chosen one is empty, but I get old collection instead. I tried to use clear/reset/load but it ...
Konrad's user avatar
  • 55
1 vote
0 answers
181 views

Order filter and search issue in admin order grid magento 2?

I have two types of order numbers( order Increment Id ) in my order table. Based on a condition i am updating the order increment id like below. EX - 000000767 To HTO-000000767 I have other orders ...
Mujahidh's user avatar
  • 2,793
1 vote
2 answers
390 views

In my data-provider addFieldtoFilter() is not working with url param

I have made a grid in admin that is supposed to return a filtered collection based on a URL parameter lesson_id. DataProvider: <?php namespace VendorName\ModuleName\Ui\DataProvider\Participants; ...
luitzen feenstra's user avatar
2 votes
1 answer
280 views

How to apply filter on magento 2 collection like below query?

THis is my core Mysql query select * from table_name where CONCAT(',', subscriptions, ',') like '%,4793,%' and i want to apply below filter on magento 2 collection. where CONCAT(',', subscriptions, '...
SURENDER SINGH's user avatar
1 vote
0 answers
144 views

Magento 2: How create ui grid filter for null values in specific column

I have a column "purchase_point" in my table. It has 3 values android, ios, and null. I need to display it in the ui grid. For the null value, I need to display 'web'. I am using the below ...
Alshihab's user avatar
  • 161
0 votes
1 answer
107 views

Magento 2 how to get product Ids in the Product listing page without pagination

I want to get the listed product's IDs in the product listing page without pagination. But the products will be listed with pagination. If it is filtered by layered navigation/search then I want that ...
Jancy Abraham's user avatar
0 votes
1 answer
1k views

Magento 2 : Get collection of based on field

Here is the collection I have as an output : Array ( [0] => Array ( [item_id] => 1 [rma_id] => 1 [product_sku] => 24-MB02 [...
Hamendra Sunthwal's user avatar
0 votes
1 answer
88 views

Magento2 collection not get set

I have added following code to change the collection. The issue is that when I print the sql query then I am getting correct result(in mysql ) but after that when I print getData on collection then ...
Arjun's user avatar
  • 3,586
0 votes
0 answers
451 views

Product Collection With Duplicates (On Purpose) For Admin Grid How?

I need to load a product collection that has repeated products in it. I get this error when trying to load a product collection with repeated products: Item (Magento\Catalog\Model\Product\Interceptor) ...
Kevin Chavez's user avatar
0 votes
1 answer
521 views

Product collection join with custom table undefined column

I am working with some product collection join with custom table, I've a custom product attribute, need to add a join condition with the product custom attribute with the custom table attribute. The ...
senthil's user avatar
  • 1,729
0 votes
1 answer
36 views

How to get all Products of all Websites/Stores?

I tried getting all products of all websites via the ProductCollection like this: $stores = $this->storeManager->getStores(); foreach ($stores as $store) { try { ...
Max's user avatar
  • 17
1 vote
1 answer
917 views

How to set an Active filter as default and clear it if we needed in admin UI component grid

I have tried 3 different ways to set a default filtering option(set entity value as current customer entity value) to my custom module's grid. 1.using _renderFiltersBefore() protected function ...
Thulya's user avatar
  • 41
0 votes
1 answer
54 views

Where should I connect model-data-access?

I am building a custom feature to create lists of favourite products. For this purpose I have created 2 models: The actual list-entity and a model representing information about a single product. For ...
Hurrpadurr's user avatar
0 votes
2 answers
825 views

How can I add virtual column to collection?

I have a output structure of $collection like this: I have array with sample data: $arr = [ 'id_1' => 10, 'id_2' => 30, 'id_3' => 20 ] I need add $arr to above collection and ...
Truong Nguyen's user avatar
0 votes
2 answers
794 views

Convert Array to Magento2 Collection

I am converting an Array to Magento2 Collection $items = $this->getItems(); $collection = $this->collectionFactory->create(); foreach ($items as $item) { $...
Syed Hassan Zamir's user avatar
0 votes
1 answer
105 views

Database loading Product Collection slow (Minutes)

I've got some third party code here that loads a larger product collection. It takes around 9 minutes to load on decent hardware. We have some 150000 SKU in the database. Collection: SQL is: SELECT ...
Alexander Gran's user avatar
0 votes
1 answer
280 views

difference between collection and repository in magento 2

I am not understanding the concept difference between collection and repository in magento2 and which is better to use. your help will be able to appreciate.
Muhammad Zahoor's user avatar
0 votes
0 answers
94 views

Magento 2 - Get random results with Elasticsuit Catalog Fulltext Product Collection

I am using a Magesuite module to get a product collection, and among other things I want to randomly select a certain number of products, fitting of course some criteria set with filters. The ...
Noob Doob's user avatar
  • 127
0 votes
1 answer
232 views

Extending custom interface and data model

I have successfully created a custom interface. My model: app/code/Vendor/Samples/Model/Orders.php class Orders extends \Magento\Framework\Model\AbstractModel implements OrdersInterface { ...
Johndd74's user avatar
0 votes
1 answer
69 views

Magento2: How to add data in child table?

I have a custom module with named A and db tab is z ok. now question is my: How to add child table? which is already I have done with PK and FK key constrains. How to add data in created child table ...
Zahid Hussain Magento's user avatar

1
2 3 4 5
31