The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [collection]

Questions related to Magento collections

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

Display content between set products on magento 2 category page

I was wondering if there would be a solution to display blocks, with content i can enter in the backend, between or after a set amount of products. I know i can display some static content at the top ...
0
votes
1answer
95 views

Mysql FULL JOIN in magento 2

How can i execute something like full join in magento 2 then set query data in my collection. Below i try to do somethig. $joinLeftCustomerSql = $connection ->select() ->from("$...
1
vote
1answer
174 views

Magento2 | MassAction Filter instance none given

I'm getting strange error when I want to use mass action in a grid : AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed to Toto\\Helloworld\\Controller\\...
0
votes
2answers
593 views

Call to undefined method addFieldToFilter() in magento 2

I have a model,resource model,collection file shown below. app/code/Magge/Custom/Model/Categrory.php namespace Magge\Custom\Model; use Magento\Framework\Model\AbstractModel; class Categrory ...
2
votes
1answer
738 views

how to retrieve Coupon Code by rule Id on Checkout Success Page?

I have coupon rule collection created at admin side and displaying rule names in the system configuration of the custom module. Actually, I wanted to get coupon code of a cart rule that has been ...
1
vote
0answers
196 views

override getLoadedProductCollection of \Magento\Catalog\Block\Product\ListProduct

I am overriding getLoadedProductCollection() in my block where performing some custom query public function getLoadedProductCollection() { $myCategory = $this->...
1
vote
1answer
444 views

Magento2: How to get product collection by attribute or category id?

How to get product collection by multiple attributes? Magento 2.0
0
votes
2answers
911 views

Magento2 how to modify admin grid collection using ui component

You guys would be knowing that usually, we are using core Magento DataProvider while creating admin grid using UI component. Sometimes, we need to add some filter or modify the basic grid collection ...
0
votes
1answer
198 views

Remove item from category collection in Magento 1.9

I have a category collection in Magento 1.9 This is my code :- $categories = Mage::getModel('catalog/category') ->getCollection() ->addAttributeToSelect('*') ->...
0
votes
2answers
173 views

Array to string conversion while trying to get product collection

I'm trying to get a product collection. I got it by function: public function getProductCollection() { $collection = $this->productCollectionFactory->create(); $collection->...
1
vote
2answers
486 views

Filter customers by custom attribute in admin grid

I added custom attribute to customer and now I want to filter customers by that attribute in admin grid (admin->customers). I want to user see only customers which custom attribute has specific value. ...
1
vote
1answer
372 views

How to ignore not avilable products from best seller product collection?

app/code/Test/Demo/Block/Widget/Bestsellerdproduct.php namespace Test\Demo\Block\Widget; class Bestsellerdproduct extends \Magento\Framework\View\Element\Template implements \Magento\Widget\Block\...
1
vote
1answer
221 views

Magento 2: Get collection in specific order

I want to get collection in specific order (apart from ASC or DESC order). Here is my collection: $productCollection = $block->getProductCollection() ->create() ->addAttributeToSelect('...
2
votes
0answers
489 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
56 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 ...
2
votes
2answers
880 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 \...
3
votes
2answers
294 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
43 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
26 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
853 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
28 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
181 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
144 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
139 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
232 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
551 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
475 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
4
votes
1answer
244 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 for-each to loop through either of the collections the page displays the collection correctly. However,...
0
votes
1answer
202 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 ...
1
vote
3answers
3k 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
98 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
190 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\...
4
votes
1answer
550 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
3k 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 ...
4
votes
4answers
5k 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 ...
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
298 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
281 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
205 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
295 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
370 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(...
3
votes
0answers
222 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
39 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
110 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
42 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?
5
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
381 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
60 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
516 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
84 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 ...