All Questions
Tagged with collection magento2
541 questions
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
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
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 ...
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
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()-&...
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
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
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
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;
...
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
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
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
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, ...
0
votes
1
answer
587
views
Magento 2 Product grid collection filtering on programmatic Qty column values
I am programatically updating the qty column values for configurable products.
Sadly, the grid filter for this column doesn't work with new values.
The underlying catalog product collection joins with ...
0
votes
2
answers
587
views
Magento 2.4, How to load multiple category data by array of category ids?
In Magento 2.4, I need to load multiple category data. How to load multiple category data by array of category ids?
1
vote
1
answer
2k
views
Magento 2: Graphql Custom collection data returns null
I'm creating Graphql for my custom module, but after
setting an endpoint and writing a query for it, does not return
any data.
Below are the files I have created for Graphql,
MyVendor/RMAModule/etc/...
0
votes
1
answer
104
views
How Can get the collection catalog_product_entity_tier_price
I want to get the collection of this table how can I do it???
catalog_product_entity_tier_price
1
vote
2
answers
914
views
Filter product collection for only products that have the image
I need to remove products from the collection that have no image. Even if they have the placeholder image I want them to be invisible.
The module code I use is this
<?php
namespace Smartwave\...
0
votes
2
answers
468
views
Apply "OR" condition in Order Collection in Magento 2.4.3
How to apply "OR" Condition on Order Collection ??
Example:-
I want to filter order collection on these 4 date on order collection.
November 27, 2020
November 29, 2019
November 23, 2018
...
0
votes
1
answer
580
views
Magento 2 CategoryFactory exclude current product from collection
I am using an extension auto-selecting related products from the same category. However, I want to exclude the current product from that list which is not really working.
protected $_categoryFactory;
...
0
votes
1
answer
3k
views
Magento 2: Get Product Collection With Multiple SKUs Filter
I'm trying to get product collection with multiple skus filter, don't know what I'm missing or doing wrong:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$...
0
votes
1
answer
672
views
Get Latest Entry For Duplicate Rows In Collection
I currently have a logs table which has the following rows which use the same order_id:
log_id
order_id
user
action
2410
1001318004
test1
Declined
2409
1001318004
test1
Declined
Inside my app/code/...
0
votes
2
answers
397
views
Magento 2 applying filters to collection reflects in all phtml
I have applied a filter in a PHTML that loads in headers. The filter is below.
In Constructor:
\Magento\Catalog\Model\ResourceModel\Category\Collection $collection
Block Code:
public function ...
0
votes
1
answer
156
views
how do I retrieve a list of order states
I'm looking for a way to fetch all possible order states in Magento 2. I found a way to fetch all Order Statuses but there doesn't seem to be a collection for order states.
Any ideas on how to ...
1
vote
0
answers
396
views
Magento 2 override resource model collection not working
I want to override Magento Reports module and it's not working. here's my code :
di.xml
<preference for="Magento\Reports\Model\ResourceModel\Report\Collection" type="SZK\Shamsi\Model\...
0
votes
0
answers
298
views
How to get the updated customer record in magento 2
I am trying to fetch the customer record which is updated. Customer update implies both customer entity as well as customer's address.
I am relying on the updated_at column which technically says that ...
0
votes
1
answer
65
views
Collection DataProvider - Strange behavior
I've been killing for hours and no result. I don't understand this strange behavior, can anyone please explain this to me? It's unbelievable ... Thanks for All!!!
$this->collection = $Collection;
$...
0
votes
1
answer
152
views
Get the average price for product collection
If there's a way in Magento 2 to get the average price for a product collection.
Or should I loop over the collection?
Thanks