Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
3
votes
1answer
1k views

How to filter product collection using ratings?

I want to filter the product collection using "Ratings". As it is not an attribute of products how can i do that? $collection = Mage::getModel('catalog/product')->getCollection() ->...
3
votes
1answer
2k views

Magento Model Filter by Category Returns No Products

I'm using Magento EE Lite (1.11.02) and I'm trying to load a collection of products by one single category. The following code functions as you would expect: public function getProductList() { $...
3
votes
1answer
97 views

How to get in stock product collection by category id in Magento 2.3.3?

I'm using Magento 2.3.3 with multiple websites store that uses different multiple stock sources(multi inventory) and I tried to retrieve product collection by category id like this: public function ...
3
votes
1answer
155 views

Magento 2: How to load data by Page using same collection object again?

I am using \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory and loading data by creating objects. $collection = $this->collectionFactory->create() ->...
3
votes
2answers
31 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 ...
3
votes
1answer
346 views

How to use FilterPool and Collection using the FilterApplierInterface

Hi fellow Magento developers! I'm currently trying to figure out how to use the FilterPool with classes instead of using it with the etc/di.xml. It should be possible to use filters in a grid ...
3
votes
1answer
250 views

Magento2 processing orders collection

I want to fetch the processing orders, How to fetch the processing orders collection in Magento2. Thanks Bestregards
3
votes
2answers
520 views

Wrong sorting with “name” attribute

I have a problem regarding the sorting with the "name" attribute. When i sort by Name the table is changing but it's not sorted by name. In app/core/Mage/Catalog/Block/Product/List/Toolbar.php i ...
3
votes
2answers
1k views

What is the difference between a field and attribute?

In Magento terminlogoy, some times variables are named attribute and sometimes name. While the case of attribute is clear and it means the attribute in the EAV model, the case of a field is not ...
3
votes
1answer
57 views

Sorting collection obtained from other object

I get categories collection from product object. I have to pick category with lowest level possible. To achieve this I want to sort collection by level and take first item. Although any method I know ...
3
votes
2answers
1k views

Magento 2: Invalid customer attribute in collection filtering

I'm getting a strange error after filtering through customerFactory. Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid attribute name: is_active. private function ...
3
votes
1answer
1k views

Magento 2 product repository

In Magento2, I understood we have to use repositories instead of collections. What I do not understand is how to add custom attributes to repository. If I do something like this: $searchCriteria ...
3
votes
1answer
295 views

SUPEE6788 and SQL statements in addFieldToFilter

At SUPEE-6788 Technical Details the Magento people give examples about how to fix Magento modules. Anyway, I have some places I found after install the SUPEE6788 patch that isn't explained in examples ...
3
votes
1answer
338 views

Magento2 PHPUnit internal method getCollectionMock. Bug or Feature?

When I was writing unit tests for one magento collection I faced with the following strange thing: Magento allows create mock for collection with it's internal phpunit method: \Magento\Framework\...
3
votes
1answer
588 views

How to get all products that are using the default ( admin ) scope values when in a store scope

I want to create a admin Grid that displays all products that are using the default ( admin 0 ) scope values when i am in a store scope. How can I filter a collection to get this desire result. Any ...
3
votes
3answers
184 views

How can I make a column sortable in Mage_Adminhtml_Block_Report_Shopcart_Abandoned_Grid?

I need to make created_at and updated_at sort-able in Mage_Adminhtml_Block_Report_Shopcart_Abandoned_Grid. Can anyone help me?
3
votes
1answer
4k views

Conditional join in magento collection

I am working in magento and now i face problem in getting my info.I created collection to fetch data , but now i want to check some value if exist i want to add new inner join to that collection.I try ...
3
votes
2answers
873 views

Can't load all products in Indexcontroller

I have a simple Indexcontroller. When I use this: $collection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('*'); ...
3
votes
1answer
5k views

How do I get the minimal price of a grouped product from a product collection?

I'm loading all products using the product collection resource model. $_categoryId = $this->getCategoryId(); $_productCollection = Mage::getResourceModel('catalog/product_collection') -&...
3
votes
1answer
7k views

Catalog price rules vs special price

I have found that magento has two separate ways of handling special prices but I don't know which is the best for my case. I found that catalog price rules are very powerful but I don't know how to ...
3
votes
1answer
38 views

Magento 2: Getting unknown category

I am trying to get a level 2 category list. I got all level 2 categories but I am also getting 2 unknown categories which are not in backend. This is weird. Here is my code public function ...
3
votes
1answer
178 views

Custom FilterList incorrectly sets Collection size in Layered Navigation

In order to add a custom filter to the Layered Navigation, I overrode the class Magento\LayeredNavigation\Block\Navigation\Category to load my own FilterList class instead of the one from core. My ...
3
votes
2answers
461 views

Magento 2.3 - Add product name column in custom ui grid with product name filter

I have added product name column in my custom ui grid. In which data displayed properly but not filtered grid by product name. Note : I set product name with comma separated in ui grid column. Here ...
3
votes
1answer
55 views

How to create a addnametoselect function for custom tables

I need to create an addnametoselect function (like in customer collection) for filtering purpose in the custom collection filter by the fields in custom Table on DB in magento2. Please, anyone, help ...
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....
3
votes
2answers
783 views

How can I get collection result “column headers” or “column names” in Magento 1.9x?

How can I get collection result "column headers" or "column names" from query? Suppose I have $data = Mage::getModel('catalog/product')->getCollection(); and I have some joins with other tables I ...
3
votes
1answer
1k views

How to get product rating collection in magento 2

I need to get product rating collection in block, and need to display it in template.Please provide me a solution
3
votes
1answer
107 views

Filter collection value from another value from another index

I create a custom attribute last_sync for customer custom attribute, i need to filter it if this attribute is null OR greater than created_at, right now i'm using code like this: $collections = Mage::...
3
votes
1answer
433 views

Add parent filter to category collection

Is the more native way of adding parent filter on a category collection other than a direct where showcased below? /** @var Mage_Catalog_Model_Resource_Category_Collection $categoryCollection */ $...
3
votes
1answer
130 views

Use External Database for a Custom Collection

I've been following this thread but I couldn't get it to work, How do I get my Collection to use a different DB connection?. I'm trying to load a collection from an external database separate from ...
3
votes
1answer
2k views

Why does the Product\Collection not respect the page-number and page-size attributes?

I'm trying to get a list of all the products in the store using the product-collections but it doesn't respect the page and page-size params. I'm using the sample data and have 174 products in my ...
3
votes
1answer
865 views

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'attr_index_245.value' in 'having clause'

I am trying to modify a customized Ajax Layered navigation to return products on "AND" base instead of "OR" (return only the products having all selected values for filter attributes.) for this i am ...
3
votes
1answer
869 views

Magento2 tries to instantiate Zend_Db_Adapter_Abstract

I've been playing with Magento 2 beta 1 and I'm trying to create a simple CRUD module for learning purposes. I shamelessly cloned the Magento_Cms module into a module called Sample_News. The Page ...
3
votes
1answer
52 views

Complexe filter in a collection

I would like to use addFieldToFilter (or other...) in a collection to make this filter : (item1 = 'value' AND (item2 = 'value1' OR item = 'value2')) OR (item2 = 'value3' OR item = 'value4')
3
votes
1answer
99 views

Collection filtering with OR and inner AND

can somebody tell what is the best way to filter a collection like this: where email='john.doe@gmail.com' OR (firstname='John' AND lastname='Doe' and city='Boston') I got a working version with this ...
3
votes
2answers
2k views

Get available option values for product collection

im currently working on a project where i have to find out the available option values for a product collection. Basically like the layered navigation but for a specific product collection. Example: ...
3
votes
2answers
70 views

collection, get product image

Sorry for my English I have this code $productCollection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('short_description') ->...
3
votes
1answer
45 views

Magento 2 - Multiple categories filter on product collection

I have a product collection $collection which is created by Magento\Catalog\Model\ResourceModel\Product\Collection code is: $collection = $objectManager->create('Magento\Catalog\Model\...
3
votes
0answers
37 views

how to use filters for new collection

I use in my decision the answer that was in this question Magento 2 Custom Collection Everything works fine, but how to filter data when they are searched? My code $collection = $this->...
3
votes
0answers
248 views

Order Collection based on Multiple Select Option Values Magento2

I have a list of products (books) with a custom eav multiple select attribute named 'authors' in magento 2. This attribute is 'visible_on_front' and also 'used_for_sort_by'. I am trying to use that ...
3
votes
0answers
230 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 ...
3
votes
0answers
60 views

Magento 2 : How to get top 10 repeated values in a column using CRUD instead of sql?

I want to get top 10 most repeated values in a column of my table, I can do so using sql but I need to do it using CRUD i.e using collections or model as magento coding standard doesn't allow naked ...
3
votes
0answers
1k views

Magento 2 filter not working on custom column

Magento 2 Filter is not working. In the below code column created through layout xml are getting filter, but on column created via column class file filter is not working. I have found that one ...
3
votes
1answer
397 views

Getting data from quote items collection issue in M1

This is my collection: $collection = Mage::getModel('checkout/cart')->getQuote()->getItemsCollection() ->addFieldToFilter('product_type', ['eq' => 'bundle']); $...
3
votes
1answer
569 views

Magento 2: performance of getCollection function

I'm currently working on a Magento 2 theme that requires collection statistics to show on the frontend. For example: what are the total number of customers at the moment. I'm using \Magento\Customer\...
3
votes
0answers
403 views

Magento 2: products collection with multi-selected values of multiple attributes

I have numbers of custom attributes with multiple selected values in magento catalog. I need to filter products by multiple attributes having multiple selected values. eg: Attribute set having a ...
3
votes
0answers
405 views

Magento 2 How to filter shared wishlist items function?

I want to add a new filter in shared wishlist items. I have used the preference method to override the block method. The problem is that the addFieldToFilter is not working. How can I achieve it? ...
3
votes
1answer
4k views

How to add collection filter to gridContainer in Magento 2?

I need to add a collection filter to my grid. I do few search on Internet but unfortunately it can't resolve my case. I'm using gridContainer instead of usual way. Here is my files: layout.xml <...