Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [collection]

Questions related to Magento collections

0
votes
0answers
36 views

Repository collection join processor doesn't work when called twice

I have a repository that has to join a table for certain filters when using getList. I noticed that Magento does this using a JoinProcessor. Everything works fine except when calling getList a second ...
2
votes
0answers
336 views

Magento 2 : collection filter error : Exception #0 (RuntimeException): Illegal state

I am having problem with collection filter I am using event catalog_product_collection_apply_limitations_after to add collection limitations In the observer i am using below code to apply filter. ...
1
vote
2answers
45 views

Magento2 Multiples fileds for the AbstractModel

How can I add more than one field in the load method of the \Magento\Framework\Model\AbstractModel $consumptionCollection = $this->_consumptionFactory->create()->load($iccid, 'iccid'); I ...
0
votes
0answers
14 views

Join tables in collection

I have a collection of products filtered in layered navigation. $productCollection = Mage::getSingleton('catalog/layer') ->getProductCollection() ->addAttributeToSelect('*'); I ...
0
votes
0answers
30 views

what is feasible getCollection with product_id filter or load for getting attribute values in magento 2

I can get product-data (like an attribute) via the load() method, but I would like to do the same thing, only filtering the collection with product_id like addFieldToFilter() and using ...
2
votes
2answers
637 views

addAttributeToSelect Call to undefined method M2

I have two custom modules and am calling one collectionfactory in other module and getting ` Call to undefined method addAttributeToSelect Collection file look like class Collection extends \...
2
votes
2answers
204 views

load customer object update issue in magento 2?

I have used below code in my controller use Magento\Customer\Api\Data\CustomerInterfaceFactory; class editPost extends \Magento\Framework\App\Action\Action { protected $_customer; protected $...
4
votes
1answer
42 views

How to select image from categories collection?

I have entity \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection And I'm trying following $categoryCollection->addAttributeToSelect('image'); but this doesn't work ...
0
votes
0answers
25 views

AdminGrid get collection on tab click / load on demand

Greetings StackExchange. I have a feature request on a admingrid. We are using Boost My Shop ERP for our shop. Is it possible for make a modification on how/when to load the collection? The ...
3
votes
1answer
560 views

Magento 2 : Is there a way to query products using Custom Attributes in Rest API Call?

I have a custom attribute setup for Books called isbn_13 Now I try to find the products using the isbn_13 values but unable to filter the results based on this. Is there any way to do this? Update: ...
3
votes
2answers
27 views

Collection fillter not working

I am trying to filter product, I having a list of product ids in an array and i want to filter product base on this ids. I want to fetch all the product which does not have this ids (Not In) How can ...
0
votes
1answer
138 views

Magento 2.2.5 get the product collection without Stock data

I am using Magento 2.2.5. In that, I am creating the products using the below code. $product = $this->objectManager->create ( 'Magento\Catalog\Model\Product' )->load ( $productId ); $product-...
1
vote
0answers
105 views

Set the default id of items in a custom collection

What I have I've created a grid in admin area which fills with this collection: protected function _prepareCollection() { $collection = Mage::getResourceModel('mymodule/mymodel_collection') ...
0
votes
1answer
112 views

addFieldToFilter not working properly

When I try to add a field to filter on my magento 2.2.4 quote collection, the quote are not arranged in the right order. $customerId = $this->_customerSession->getCustomer()->getId(); ...
1
vote
1answer
180 views

Getting current request page size

I need to get current page request size which could be set by an input field named limit. I can get this when it's newly set using getParam('limit') on current request object. But later it seems its ...
0
votes
1answer
394 views

Magento product collection override sort order with own order

I'm using Magento 1 and inside catalog/product/list.phtml I use the following code to add a custom sort order product_on_top: <?php $_productCollection=$this->getLoadedProductCollection(); $...
1
vote
2answers
330 views

Magento2 How to Get Newsletter Subscribed Collection into phtml file

I used Magento 2.2.4 Version. Magento2 How to Get Newsletter Subscribed Collection into phtml file
3
votes
0answers
178 views

loop through 2 collections with in one phtml

I am working on a custom module that is pulling in 2 different collections. When I try to use a foreach to loop through either of the collections the page displays the collection correctly. However, ...
0
votes
1answer
172 views

Custom sort order for loaded collection?

I have a product collection created by Magento for the category product list. I then pass some information about this collection to an external method that returns the entity IDs in a specific sort ...
0
votes
3answers
2k views

Magento 2 How to get only one field data in collection

I want to get only one field data in my custom module collection. For ex: getting following data in collection: Array ( [0] => Array ( [banner_id] => 1 [banner_title] =...
0
votes
1answer
57 views

Magento 2.2.5 : setData save records array vise

I have so many fields in my custom table. When, I update records at that time, I save records as like below code : $myModel->load($id); $myModel->setData('field_1',$field_1); $myModel->...
1
vote
0answers
135 views

Pagination not working in custom grid collection

I have created the grid with custom collection filter grid displayed proper but pagination not working. Any have an idea about the same. Please find below my code <?php namespace Abc\Xyz\Block\...
0
votes
0answers
22 views

How can I apply natural sorting to a collection in Magento 2?

I want to sort a collection in Magento 2 using natural sort. I know a can do a simple $collection->getSelect()->order(...) to do the sorting directly in MySQL, and I know that would be the ...
4
votes
1answer
439 views

One to many relationship in M2

I am working on a module where I have to implement one to many relationship. I have one table for series with id and name field and one table series_product where I have id, series_id, product_id and ...
4
votes
2answers
2k views

How to get configurable attribute label and value in magento 2?

To use Object Manager is not a proper way but this code is for testing purpose only. I want to get attribute value which is available in configurable products. I have tried with below code, but I get ...
0
votes
0answers
167 views

Delete quote which has not been converted to order

How to delete quote collection which has not been converted into order and the quote was created yesterday and the day before that ?
2
votes
4answers
3k views

Get quote item collection by using quote item id in Magento 2

I get the quote_item_id like this: $orderItems = $order->getAllItems(); foreach($orderItems as $orderItem){ $qouteItemId = $orderItem->getQuoteItemId(); } I need to load quote item ...
0
votes
0answers
438 views

Magento 2.2.4 wishlist count not display on top of the product category page

I used my custom theme, i facing some problem related to wishlist count. Wishlist count display on product detail page but not display on product category page, Home page and other pages. i am stuck ...
3
votes
3answers
1k views

Magento 2 addFieldToFilter equal today for datetime field

I have a model with field in datetime format, i want to filter the field with equal today date like this: $collections = $this->customFactory->create()->getCollection() ->...
0
votes
1answer
183 views

Magento 2 bind param to query in order by clause

I'm trying to bind params to order by with expressions clause in Magento 2, my insecure code looks like: $order = new \Zend_Db_Expr("POW((main_table.long - $this->_coordinates['lat']), 2) + POW((...
0
votes
2answers
200 views

Modifying product collection for list page not working in magento 2

I am trying to Modify Product collection which provides collection for product listing page aka category page. For this I have overridden _getProductCollection function of Magento\Catalog\Block\...
0
votes
0answers
188 views

How I can Filter admin Order collection by status (Pending Only)?

How can I filter admin order collection and showing only pending orders in grid? So how can I extend it in custom module? Any suggestion about that?
0
votes
1answer
280 views

Removing items from quote depending on custom condition

I am trying to use sales_quote_item_collection_products_after_load to remove items from a quote depending on a custom condition. public function filterQuote(Varien_Event_Observer $observer) { /** @...
0
votes
2answers
267 views

Magento 1.9 : How to combine two collection data?

I have two different collection one is of order payment transaction and other one is of sales order as show below: $transactionData=Mage::getModel('sales/order_payment_transaction')->getCollection(...
2
votes
0answers
196 views

Magento 2: Filter by custom product/category attribute returns 0 results

I created a bool (int) attribute with a default value of 0 for both category & product entities. I reindexed, cleared cache, etc... Now, no matter what I do, I can't filter the collection using ...
1
vote
0answers
34 views

Magento 2: Custom product collection with layered navigation [duplicate]

How can we load custom product collection with layered navigation? Same like search result page but with custom product collection. I have checked here Magento 2 - Layered Navigation for Custom ...
1
vote
0answers
81 views

Filtering grid by using filter_url_params is not working

I added a grid to a ui_component form and I want to use an Url-parameter to filter the content of the grid. Herefore I added the 'filter_url_params' in my listing: <dataSource name="...
0
votes
0answers
40 views

How to limit products category based per user in magento 1.9.1.0?

I want to limit products category based per user. For example, If I have added free category under 10 products. Users only can order 1 to 7 products within free 10 products. Any idea regrading this?
4
votes
3answers
1k views

Incorrect product count in layered navigation after overriding list product collection

I have customized(override) product list collection getProductCollection and filtered collection as required. public function getProductCollection() { if (isset($this->...
0
votes
2answers
305 views

Out of memory on collectionFactory->create()

I'm getting a strange error on code which previously worked and now dont. <?php namespace Itstod\LinkedProducts\Model; use Itstod\LinkedProducts\Api\LinkInterface; use Itstod\...
1
vote
1answer
50 views

What is the role of the `load()` method in the collection class?

In Magento\Framework\Data\Collection there is a method getFirstItem which calls $this->load() public function getFirstItem() { $this->load(); ...} load method from the same class: /** * ...
0
votes
0answers
410 views

Magento pagination how to set page number for custom collection?

I have a custom collection of around 900 wordpress blog posts I have used custom pagination for this custom collection. The problem is, when i click on the pagination button, the pager URL seems to ...
0
votes
1answer
59 views

How the upsell products handled in view page?

How magento 2 displayed only the in-stock upsell products in view page. How they handled and displayed I wish to display upsell product collection in list page on each product. I got the upsell ...
0
votes
1answer
254 views

How to get quantity of products sold?

I need to get the quantity of products sold on my report module. Actually I'm only getting the ordered quantity, but I need to get the quantity of all finished orders. Here is my actual code: public ...
1
vote
3answers
806 views

How to JOIN TABLES with WHERE clause in Magento 1.9?

I want to join two tables, the customer_entity, and customer_entity_varchar. but I have no idea how to do it. This is my current query: Let's assume I the entity_id is 5 and attribute_id is 139. $...
0
votes
0answers
67 views

Magento 2: How to add Join query in a custom module

want to add join query in getPost function in a single view public function getPost() { if ($this->_post === null) { /** @var Post $post */ $post = $this->...
0
votes
2answers
161 views

How can I get a collection with all payment methods?

I need to get a collection of all payment methods and list the quantity of orders on each of them, how can I do that programmatically?
1
vote
1answer
124 views

How to get billing address from sales/order_grid_collection?

I have sales/order_grid_collection where I'm getting the desired attributes on my grid, but the last one attribute I need is the billing street of the order, how can I get that programmatically? ...
2
votes
0answers
210 views

Create filter group inside foreach dynamic filters

I'm following this link to create a filter group to be applied to my custom collection. searchCriteria => [ 'filterGroups' => [ 0 => [ 'filters' => [ 0 => [ ...
1
vote
0answers
228 views

Magento 1: $productCollection->getData() vs foreach ($productCollection as $product)

I have Magento product collection with some filters. when i call $productCollection->getData() I have right result, but foreach($productCollection as $product) gives wrong products. why its ...