All Questions
Tagged with custom-collection or collection
1,670 questions
0
votes
2
answers
48
views
After Upgrade Magento version from 2.3.5 to 2.4.7, an error in the Admin Grid(Custom module) started to appear
After a magento update was made from version 2.3.5 to 2.4.7, an error in my custom module started appearing in the administrator. In the main view inside the administrator shows me the following error:...
0
votes
1
answer
67
views
Magento 2 SimiCart - Magento 2 Mobile App Builder
We are using Magento 2.4.2-p2 version with SimiCart - Magento 2 Mobile App Builder
We are struggling from where category_id is coming
File name - app/code/Simi/Simiconnector/Model/ResourceModel/...
0
votes
1
answer
38
views
Magento 2 - How to filter on multiselect product attribute with AND condition
I have two custom product attributes. both attribute type is Multiselect. I want a product collection using a filter of both attributes.
I have tried with below solution but it not working.
$...
0
votes
0
answers
28
views
Magento 2 : Pager not work in my custom collection
I have a custom collection for ordered products for a customer.
$connection = $this->resourceConnection->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);
$...
0
votes
1
answer
47
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 ...
0
votes
0
answers
32
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 ...
0
votes
0
answers
13
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,
...
0
votes
1
answer
33
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 ...
0
votes
0
answers
29
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 ...
0
votes
1
answer
48
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 ...
3
votes
0
answers
280
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
47
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
741
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
57
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
3
answers
721
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
2
answers
511
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
2k
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
307
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
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, ...
2
votes
0
answers
110
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
107
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
153
views
Product Collection Methods: addFieldToSelect() vs. addAttributeSelect()
What is the difference between ->addFieldToSelect('name') and ->addAttributeToSelect('name')?
0
votes
1
answer
29
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
68
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
2
votes
2
answers
630
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
2k
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\...
2
votes
1
answer
269
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 ...
2
votes
1
answer
1k
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\...
2
votes
1
answer
246
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
225
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 ...
1
vote
2
answers
487
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;
...
2
votes
1
answer
327
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
168
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
128
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 ...
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
[...
0
votes
1
answer
109
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
502
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
612
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
44
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
1k
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
56
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
974
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
1k
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
118
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
350
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
119
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
256
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
76
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
677
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, ...
0
votes
1
answer
529
views
How to get custom attribute value in after product collection load in Observer
I want to get multiple select type custom attribute values in product collection observer,
I have tried with some events catalog_block_product_list_collection, ...