Questions tagged [collection]
Questions related to Magento collections
1,533
questions
0
votes
1
answer
40
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 ...
2
votes
0
answers
88
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 ...
0
votes
0
answers
17
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 ...
0
votes
0
answers
17
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 ...
0
votes
1
answer
155
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/...
1
vote
1
answer
50
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 ...
0
votes
0
answers
40
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 ...
0
votes
3
answers
192
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 <= '...
0
votes
0
answers
10
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 ...
0
votes
0
answers
16
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 ...
0
votes
0
answers
18
views
Why is the number of items on the page displayed incorrectly after adding a addCategoriesFilter?
Filtering works, but it breaks the number of items on the page (products hidden by the filter disappear), for example, was 12, the filter on the page found 2, removed them and now the page collection ...
0
votes
0
answers
22
views
Get swatches / filter for a custom page with product list
I have a form that i'm using to load a custom collection.
That collection is properly printed on my page. But the swatches / filter are not linked to my custom collection they act like is they were ...
0
votes
2
answers
159
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 ...
0
votes
2
answers
780
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 ...
0
votes
1
answer
83
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()-&...
0
votes
1
answer
23
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, ...
2
votes
0
answers
52
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 ...
0
votes
1
answer
36
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 ...
0
votes
1
answer
77
views
Product Collection Methods: addFieldToSelect() vs. addAttributeSelect()
What is the difference between ->addFieldToSelect('name') and ->addAttributeToSelect('name')?
0
votes
1
answer
23
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(...
0
votes
1
answer
45
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
0
votes
0
answers
141
views
How to replace default filter of a specific field by custom filter in admin grid of custom table . Still keep pagingnation, other filter
In Admin grid filter type select.By default Magento, it will add this string to SQL query Where main_table.my_field = 'my-value'. Now I want it will be Where FIND_IN_SET('my-value',main_table.my_field)...
0
votes
0
answers
158
views
Magento 2 Edit getLoadedProductCollection on Block with a plugin
I am trying to edit the product collection in category page.
Every time I try to load and edit the collection
vendor/magento/module-catalog/Block/Product/ListProduct::getLoadedProductCollection()
or ...
2
votes
2
answers
207
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('...
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\...
0
votes
0
answers
11
views
Load data in Admin Product Listing except some entities included in some other database table!
I want to show all the products in product listing except some entities which are included in some other db table (these entities are also included in catalog_product_entity table), I just want to ...
1
vote
1
answer
169
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 ...
1
vote
1
answer
468
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\...
1
vote
1
answer
134
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 ...
1
vote
0
answers
148
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 ...
0
votes
2
answers
250
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;
...
0
votes
0
answers
101
views
Magento 2 get Custom collection query for JSON column condition
How to write below query in getcollection.
select * from mp3_extracteddata WHERE json_extract(mp3_information, "$[0].tracks.title") = 'Do It Better'
1
vote
1
answer
223
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, '...
1
vote
0
answers
122
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 ...
0
votes
1
answer
99
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 ...
1
vote
1
answer
809
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
[...
0
votes
1
answer
61
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 ...
0
votes
0
answers
370
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) ...
0
votes
1
answer
372
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 ...
0
votes
1
answer
29
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 {
...
1
vote
1
answer
743
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 ...
0
votes
1
answer
49
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 ...
0
votes
2
answers
635
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 ...
0
votes
2
answers
602
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) {
$...
0
votes
1
answer
83
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 ...
0
votes
1
answer
192
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.
0
votes
0
answers
68
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 ...
0
votes
1
answer
197
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
{
...
0
votes
1
answer
53
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 ...
0
votes
3
answers
510
views
Collection does not return the intended results
I am working with the collection from a module trying to return specific information. The database has several columns but I only want 2: "region_id" & "default_name". But, ...