Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
0
votes
2answers
383 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
225 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
112 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
43 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
396 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
61 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
537 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
88 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
315 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
1k 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
82 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
301 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
189 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
266 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
236 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 ...
0
votes
1answer
596 views

Magento 2 : Join 2 tables in Existing collection

I've been trying to join 2 tables with the existing collection of Customers (customer_entity). I've added like below. $items->getSelect()->join('customer_entity_text as second', 'main_table....
1
vote
2answers
2k views

Magento:2 How to Image upload in custom module

Image upload working fine in tmp folder, then store in DB. I want to after saving data image stored in the base folder pub/media/events var_dump($data); " ["events_url"]=> array(1) { [0]=> ...
2
votes
2answers
3k views

Magento 2 - product collection filtered with custom attribute

I would like to filter product collection on category page using custom attribute. For example: On category page, I want to list only products that have custom attribute age set to 10. How to ...
1
vote
0answers
378 views

Magento 2 : Get Customer Collection with it's Attribute

I've managed to get customer collection using class \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory but it returns me default details not with Created Customer Attributes. Any ...
1
vote
2answers
3k views

how to get block data on phtml template in magento 2

what is missing in my code block data not shown in phtml template block page namespace xxxx\Trails\Block; use \Magento\Framework\View\Element\Template; use \Magento\Framework\View\Element\...
0
votes
1answer
127 views

Get collection with promotional products not working

I need to get a collection listing all products with a promotion, but I'm getting this error: Fatal error: Call to a member function getBackend() on boolean I tried those 2 solutions, but still ...
1
vote
1answer
271 views

Use search_criteria to filter custom extension collection in Magento 2

I generated a custom extension with a custom model collection from mage2gen , is it possible to implement the search_criteria like when you retrieve product using rest api? what i know is the product ...
3
votes
1answer
1k views

Magento-2 get all products having product qty less than 5 only

I'm trying to get product collection, only the products which have the qty less than 5 in Magento 2, but I'm failing to load. use Magento\Framework\App\Bootstrap; require DIR . '/../app/bootstrap....
0
votes
2answers
266 views

addFieldtofilter array not reading

I am trying to filter product collection by ids if I use below code, the filter works ok and the product shows. $this->_productCollection ->addFieldToFilter('entity_id',array('in'=&...
1
vote
1answer
308 views

Filter collection with attribute from custom module

I have a custom module which I load data with following code inside list.phtml: foreach ($_productCollection as $_product){ $_id = $_product->getId(); $event = Mage::getModel('aw_eventbooking/...
0
votes
1answer
282 views

Magento 1.9 join table issue

I'm having an issue with Magento 1.9.2.4 trying to make a join on my collection, here's the problem: Actually I've got a custom table named product_banner which I'm getting by: $collection = Mage::...
0
votes
3answers
107 views

Magento 1.9 : Error getting collection Model of Catalogrule

I try to get a collection of Mage::getModel('catalogrule/rule') but when I do Mage::getModel('catalogrule/rule')->getCollection() I have an error because can't call a function of boolean. I do a ...
3
votes
3answers
2k views

Magento 2 : setOrder not working in collection

In my custom collection $career_collection->setOrder('career_id','ASC'); not working. My function is below public function getAllCareers(){ $Careers = $this->_careersFactory->create(); ...
4
votes
1answer
490 views

How to use collection factory model in Unit Test magento 2

I have a custom extension with model with structure like this in database: +----------------------------------+ |entity_id | customer_id | balance | +----------------------------------+ | 1 | ...
1
vote
1answer
117 views

Magento 2.2.3 :: How to check if ProductCollection exists?

Here is my problem: I have a vehicle parts site which lets user select their specific model and be saved via a cookie. Then the whole site will be filtered via my module plugin, where I override “...
2
votes
1answer
219 views

Get collection of recently updated products

I'm trying to create a collection of all products that have been updated in my store the past 24 hours. The following code seems to be ok to me. Although I have tried numerous altering versions of it,...
0
votes
1answer
104 views

How to get collection object when use where in collection

I am trying to add where in collection but it return Varien_Db_Select Object instead of return collection object. $collection = Mage::getModel('orderoutofuk/orderitem')->getCollection()->...
0
votes
1answer
333 views

Magento 1.9 custom collection pagination not working in admin grid?

I have created a custom grid to show a monthly wise report, But the pagination is not working with the Varien_Data_Collection . Please find the code snipet below from Grid.php $rows = $...
1
vote
2answers
263 views

Magento 2.1 - Memory Leak in my getCollection function

So I'm creating a really simple module to read from a custom table. Nothing fancy, table has two rows: +-----------+--------------+ + status_id + status_label + +-----------+--------------+ + 1 ...
1
vote
1answer
234 views

MEQP Gives a Warning : Data load getFirstItem() method detected in loop

I want to get the First item from the collection so I have used following code. But it gives some warning on the usage of getFirstItem() protected $_sampleFactory; public function __construct( \...
2
votes
1answer
307 views

Magento product collection filter not working

I am using magento list file class with override productlist.php.So i can use product collection object and try to filter using type_id but nothing happend. Here is my code. <?php use Magento\...
0
votes
1answer
151 views

Magento 2: toolbar url problems in custom module with custom router

I have the custom module with product collection and custom router. for example i want to have link https://domain.com/gaires/something Router code: namespace UseApp\Gaires\Controller; class Router ...
0
votes
2answers
55 views

Magento 2 How to load product collection, Category collection, Load product by child ID

I have some experience in M1 and M2 but am somewhat struggling to grasp how to load the child category. At the minute it loads the default M2 category with [0] or [1] next category etc. But I just ...
1
vote
1answer
603 views

sql - joinLeft collection sales_flat_order_grid

I have this SQL query: select main_table.*, (select nexway_status from nexway_order where order_id=main_table.entity_id ORDER BY id DESC LIMIT 1) as nexway_status from sales_flat_order_grid as ...
0
votes
2answers
487 views

How to write inner join query in collection method (magento2)?

How to write this query in magento2 collection method? SELECT o.increment_id , h.status, h.created_at FROM sales_order AS o INNER JOIN sales_order_status_history AS h ON h.parent_id = o.entity_id ...
0
votes
1answer
640 views

Displaying products on the front page does not work

Magento 1.9.3.7 Porto theme I did a fresh install of Magento 1.9.3.7. I installed the Porto theme. The setup is identical to the one I have in Magento 1.9.1 but when I put the following code into the ...
0
votes
1answer
886 views

Magento 1.9 Cache Custom Block Data

I have a custom module that displays products from a given category in a carousel. Now, I was wanting to cache the results, so the database is not queried and duly for speed optimisation. However, I ...
0
votes
1answer
133 views

How to write sub-query with group by in Magento 1.9?

I am new in learning Magento. I need to create query like this, SELECT * FROM YourTable WHERE ARIDNR IN ( SELECT ARIDNR FROM YourTable GROUP BY ARIDNR HAVING COUNT(*) > 1 ) How to write this ...
0
votes
1answer
141 views

Magento 2 Category Collection doesn't show items not in Top Menu

I am trying to display certain categories along with their images on homepage. I've made sure the categories dont appear in the top menu and only in the code that I am trying to use. Below code only ...
1
vote
2answers
27 views

Simple type products collection - wrong count

Here's a collection that should include all simple products in my magento store: $collectionSimple = Mage::getModel('catalog/product')->getCollection() ->addAttributeToFilter('...
1
vote
2answers
502 views

Collection filter date range not working

I tried to find the collection that has a range created between 4 hours, but somehow it doesnt show the right collection size, it always returns '0', here's how i use the filter: $to = date('Y-m-d H:...
4
votes
0answers
87 views

How to handle multiple tables with magento 2 repositories?

As we all know, magento 2 suggests using repositories as an additional layer between resource models/collections and the rest of application. It's all pretty straightforward and simple when you use it ...
0
votes
1answer
576 views

Magento 2: Sort multilevel category collection by both level and position

I am using Magento 2.2 and I want to get a collection of categories that is made up of a number of sublevels of a specific category. How can I get this collection sorted by both level and position so ...