Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
0
votes
0answers
16 views

Magento 2: How to work with larger collection of data that the site shouldn't load too much?

I'm using this store locator extension in my 2.3.1 local. I have 1000 stores in the backend imported by using CSV. On the frontend, while I search that store address it should find the stores from ...
0
votes
1answer
12 views

magento2, create correctly SELECT used collection

i have this code $collection = $this->orderCollectionFactory->create() ->addFieldToSelect(['increment_id', 'global_currency_code', 'status', 'updated_at', 'total_due', '...
0
votes
1answer
15 views

Magento 2 multiple AND/OR conditions

I have a collection and I want to filter like this: WHERE field1 >= '2020-01-01' OR (field2 == 'open' && $field3 == 1). How can I achieve that?
0
votes
0answers
10 views

Magento 2.3.5p1 In widget.xml can I load collection? [closed]

I am trying to load a collection in widget.xml, I have been looking everywhere and I am not able to find a solution. Please can someone help me or give me a tip
0
votes
1answer
45 views

Magento2 - Order collection, How to get billing address?

I have below code. $collection = $this->orderCollectionFactory->create() //['increment_id', 'global_currency_code', 'status', 'updated_at'] ->addFieldToSelect('...
0
votes
0answers
12 views

Load Config Collection including config.xml values

I need to load all configs with some filter, including values, that defined in config.xml files. Here's some code to make some clarity about what I need to do: public function __construct( \...
0
votes
0answers
11 views

How to add pagination on custom collection with joining tables in Magento 2

I am joining 3 tables with my custom table and data are showing in the admin grid is perfect but in the pagination, first, new clicks are working eg: when we on 1st page pagination next link working ...
0
votes
0answers
21 views

Get shipments by order number in Magento 1.9 API

I am trying to get the list of shipments for a given order via the API (I use the SOAP API but I don't think it matters). I don't have the order ID but the 9-digit number (the increment_id from the ...
0
votes
2answers
32 views

collection filtter not working in magento 2

collection fillter $prodColl = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection'); $collection = $prodColl->addAttributeToSelect('*') -&...
0
votes
0answers
19 views

How to product add to cart using custom module(Tabs) in magento 2.3.5-p1

How to product add to cart using text-area. I want to create text-area in which customer can add product-sku,qty and clicking on add to cart button then that product will be add to cart. How to add ...
1
vote
1answer
93 views

Magento 2.3 Custom Filter Layer Navigation Error: The attribute model is not defined

I have a custom product attribute brands, this is a dropdown option that has dynamic select value, basically i want to add a custom layer navigation filter to check whether the product attribute value ...
0
votes
0answers
9 views

I have bundle product and got its id I want to get the bundle option for that product

I want to get collection of bundle option_id from table "catalog_product_bundle_option" related to the parent_id which I have passed
1
vote
1answer
37 views

Magento 2: Product collection filter with custom attributes with like

I am using magento 2.3.3 i have custom module in that i am using search when any one search i am filter products name like it is working fine but now i want add extra attributes.I have created product ...
1
vote
3answers
47 views

how to get parent category collection dependency injection magento 2.3.1

How can I get a first category level from Magento 2.3, my category setup looks like this now. root_catalog |-First |-Shoes |-T-shirts |-Brands |-Demo |-Test Now First ...
1
vote
2answers
44 views

Missing required argument $mainTable on Collection

I have a custom grid, where it gets some data from the shipment table. This is the error message received: Missing required argument $mainTable of Vendor\Module\Model\ResourceModel\Order\Shipment\...
2
votes
1answer
67 views

Filter Magento2 Fulltext\Collection by OR condition

How can i filter the Magento2 Fulltext\Collection (Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection) by an OR condition between 2 product attributes, with respecting also the ...
0
votes
3answers
43 views

Magento 2 : Get Product Collection based on Attribute

I want to get product collection based on attribute. For ex : If "Size" attribute exist in "Bag","Bottom" attribute set then, All Product's of Bag and Bottom return in ...
1
vote
1answer
20 views

I am facing this error while fetching data to admin grid in Magento

I am facing this error while fetching data from custom table in Magento 2.3.5 the error is: Argument 1 passed to Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider::...
0
votes
1answer
30 views

How to join a custom table and show its attribute on Magento 2 rest Api getList() function?

Im creating a custom product Api with searchCriteria from \Magento\Catalog\Model\ResourceModel\Product\Collection And I joined other table to this collection; public function getList(\Magento\...
0
votes
1answer
23 views

convert sql query to magento addFieldToFilter combine OR and AND

You can convert me this sql I did not arrive at combined OR and AND at the same time SELECT * FROM sales_order AS main_table, sales_order_payment AS sop WHERE ((status = 'processing') Or ((status = '...
1
vote
1answer
33 views

Category CollectionFactory issue

Can anyone see what I am doing wrong here. It displays All categories instead of only showing the specific website/store categories. $collection = $this->_categoryCollectionFactory->create(); $...
1
vote
1answer
20 views

Magento 2 print phtml product collection

When I try to get product list in a controller for a ajax module like this : echo $this->layoutFactory->create() ->createBlock('\Magento\Catalog\Block\Product\ListProduct') ...
0
votes
1answer
25 views

Magento 2 Filter Orders Based On shipping Country

I want to Filter Orders based on Shipping country I have filtered using other attributes like grand_base_total and store_id but struck at shipping country as there is no any attribute for that in ...
0
votes
2answers
14 views

Magento2 addFieldToFilter, Need 'and' and 'Or' in sql

I need magento sql collection. Query need like that. select * from custom_table where customer_id=xx or (customer_group=1 and custom_field=1) I can add or operator like below select * from ...
1
vote
0answers
12 views

SearchCriteria vs Collection - Query Performance Difference

I am trying to refactor get category data method. Initially, it was written with Collection filter. Later I refactored with the search builder interface. When I tried to compare the querying time, I ...
0
votes
1answer
21 views

Pagination in Custom Collection magento 2

I am retrieving data from third party as an object, I am forcefully converting an object into array and collection. I want to apply pagination with the data, I tried using core pagination logic and ...
0
votes
0answers
29 views

Get current product details in price phtml file in magento 2

I want to get current product details in /Magento_Catalog/templates/product/price/amount/default.phtml file. I want to display custom price as per my requirements. so i need to get product collection ...
0
votes
0answers
17 views

Magento 2 Get Request Param Always Null

I can't seem to get request params from a Data Provider. I've modified Magento\Review\Ui\DataProvider\Product\ReviewDataProvider.php to log (also tried var_dump) the information, but it always returns ...
0
votes
0answers
30 views

I am getting incorrect count of products for layered navigation in magento 2.3

In layered navigation filter i am getting incorrect product count, i can't get the solution for this problem. Example : The products under Shorts category in 49 but in the filter for me showing as ...
0
votes
0answers
32 views

Magento 2 - How to use mysql find_in_set?

In Magento 2, I try to use find_in_set mysql function but without success. I try this : $result->getSelect()->order("find_in_set(e.entity_id,'".implode(',',$sort_order)."')"); But it give me ...
0
votes
0answers
11 views

customer custom filter is not working in customer grid admin

I added filter with custom table.i'm getting the all customers even i pass filter parameter. backendurl/backend/customer/index/index/practitioner/22 protected function _initSelect() { ...
1
vote
1answer
25 views

In magento 2 on product collection both addFieldToFilter and addCategoryFilter is not working

I am trying to get the product based on the 3 rules. 1st rule -> the product should have been created within a month 2nd rule -> it should be belonging to a particular category 3rd rule ->it should ...
1
vote
1answer
21 views

Out of stock products: why do they appear in Collection::getAllIds and not in Collection::getItems

Im trying to get all products in a collection: out of stock and products in stock. So what I did is: /** @var $collection \Magentp\Catalog\Model\ResourceModel\Product\Collection */ $collection = $...
0
votes
1answer
42 views

How to get list of orders filtering by payment method

I would like to get a list of orders which have been made by a specific payment method using the search criteria. Is there any way we can achieve this? The only thing I've found is this thread: ...
0
votes
0answers
13 views

Apply filters or mass actions on grids with fake collection (or wirhout ui components)

I a admin grid with a change on _prepareCollection() function to get the collection from a response of api call, its working fine. But I do not have the filters or mass functions, how can I do that ...
0
votes
0answers
15 views

How do I get all products in a category?

Consider my 'shorts' category below. It has 149 products in. 13 are configurable, the rest are simple products that have a visibility of 'Not visible individually'. I have the following: $category = ...
0
votes
0answers
9 views

Megento 2 Left joining two tables, if null default to 0

Title self esplicative, but when I perform the join, then add field to select then make the expression I get an error. $this->getCollection()->getSelect() ->joinLeft( [ ...
0
votes
1answer
47 views

Show products with zero quantity last in Magento 1.9

I want to show products with zero quantity last in all site categories, search results, etc. But the sort order should be as follows: the products with a non-zero quantity (not in decreasing, default (...
0
votes
0answers
16 views

Magento2 : Join Another Table in Existing Collection

Lets say, Third party collection class is as below: namespace Vendor\ShipRule\Model\ResourceModel\Rule; class Collection extends Magento\Framework\Model\ResourceModel\Db\Collection\...
1
vote
1answer
26 views

For each Loop Not Print Proper Data

On product listing page I have $_productCollection = $block->getLoadedProductCollection(); if I call getData on $_productCollection I get different array than I get in foreach loop. Does anyone ...
0
votes
0answers
25 views

How to display collection data in grid ui admin?

I create controller to get data from database as code below. The query in controller: $orderCollection = $this->_salesOrderCollectionFactory->create() ->addFieldToFilter( ...
0
votes
0answers
24 views

magento 2 data import in custom table data import

During Magento import i have created one observer for import some in my custom table also. It is imported my custom table by using foreach ($collections as $collection) { ...
1
vote
1answer
34 views

Magento 2: Filter Product Collection using Category Id always return empty set

I have a parent category with subcateogry that contains a lot of product in it, when i tried to filter the product collection using this parent category id, it always return an empty collection: ...
0
votes
1answer
29 views

Load Customer Model by Extension Attribute in Magento 2

How can I load the Customer Model and Collection by Extension Attribute in Magento 2? I've declared an extension attribute in extension_attributes.xml and saved to the Customer Model. Now, How can I ...
0
votes
1answer
20 views

magento, how correctly create sql request to database used colleciton, AND condition

i have this code $collection = mage::getModel('purchasemanagement/purchasemanagement')->getCollection() ->addFieldToSelect('item_id') ->addFieldToFilter( ...
0
votes
2answers
67 views

Magento2.3: How to collect the data by time?

I want to collect the records from 10PM to 5AM of wishlist data. I have already created a module and not sure how to filter the records by this timeframe. The wishlist table contains a field called ...
0
votes
0answers
41 views

Laravel API integration with Magento 1.9

How can I integrate laravel api to get products from laravel site and show with magento's product list page.
0
votes
1answer
96 views

get order collection by product attribute option value in Magento2

I am trying to fetch full order collection by product attribute option. I have a "brand" attribute with options "option_1", "option_2", "option_3". This attribute is assigned against each product sku....
0
votes
1answer
22 views

How set value for attribute?

I have this code: foreach ($skuScope as $sku) { $object = Mage::getModel('catalog/product'); $product = $object->loadByAttribute('sku', $sku); $attributes = $product->getAttributes(...
0
votes
0answers
9 views

Search in database with some special characters, Magento 1.9

I have value of a attribute having different kind of formats, Some are given here: 1. 9-1/2" x 32" 2. 32" 3. 6" x 7-3/4" 4. 111221 X .041 RIVET 5. .060" - 6.500" 6. 0.11" to 1" (Tapping Range) 7. 1 ...

1
2 3 4 5
32