Questions tagged [collection]

Questions related to Magento collections

1
vote
0answers
171 views

removeItemByKey not working in product collection - Magento 2

I have a product collection (\Magento\Catalog\Model\ResourceModel\Product\Collection $collection), I try to remove some of the item from the collection by using below code. foreach ($collection->...
1
vote
0answers
79 views

getCollection()->getSize() not returning correct number of records

getCollection()->getSize() not returning correct number of records. Here is my code : /** @var $collection Mage_Reports_Model_Resource_Report_Collection */ $collection = Mage::...
1
vote
0answers
131 views

Magento 2 Add 'Remove out of stock' filter in category page and search results page

I have to add 'Remove out of stock' filter on the category page and search results page. By default i m displaying all products which is in stock or out of stock. Any suggestions please? i m not ...
1
vote
0answers
100 views

Manadev Multiple Select and Sort By Price not working

I have installed Manadev Multiple Select extension which i thought was pretty good for a while until i noticed the sort by price didn't really work. I cannot quite figure out why however have enabled ...
1
vote
0answers
395 views

How to change the category collection before load?

I'm trying to figure out how to change the category collection before load. To be more specific, I've created a category 'Sales'. The category is empty with no products. I want to automatically add ...
1
vote
0answers
467 views

How to sort products by bestsellers (e.g. by sales) in Magento 2

these days I've faced a problem: I needed to to sort products by sales. So, first of all I decided to add this field to collection of products and the order it using method $collection->setOrder(). ...
1
vote
0answers
365 views

magento 2 get product collection with custom filter on product listing page

I want to apply my custom attribute filter in category product collection? Can any one inform me for that ,i need to override which file ?
1
vote
0answers
393 views

Magento-2 How to change product collection based on categories

I want to change core product collection based on categories, exclude some categories product from product collection. For Example : Main Category - 4 Child categories - Access only 3 categories. ...
1
vote
0answers
55 views

Magento 2: Use widget with standard product list template

Is there way to use the same template like the "new products" widget magento already has but with my own product collection? I know how to make a widget but i don't how to attach the standard ...
1
vote
0answers
89 views

Group by products by attribute in minicart - Magento1.9

I want to know how to group by the products of a minicart by vendor_id attribute, evidently each product has this attribute vendor_id. Then I display at the header of each group the name of the vendor,...
1
vote
0answers
224 views

how to join Query for particular customer group and custom customer_entity_varchar attribute?

Here in my collection -> Table structure is : 1,id, mydb,table_name,INT UNSIGNED,,10,3,0 2,userid, mydb,table_name,INT UNSIGNED,,10,5,0 3,transctionid, mydb,table_name,...
1
vote
0answers
352 views

How to load a model with relationships via repository in Magento 2?

Background story: I was trying to load a model with model_store relationship using this snippet. I failed to do that with my own model. Model is being loaded without store data. Some debuging later I ...
1
vote
0answers
172 views

add conditional filter to sales_order_grid collection (magento2)

I want to add a custom filter to the order collection, checking if some conditions are met. A helper method should return false/true, and then apply the custom filter if it returns true. The custom ...
1
vote
0answers
60 views

Magento 1: Different collections from external script and from helper

I have a custom product resource collection, which I need to export to CSV. The collection is made up like this: /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */ $collection = ...
1
vote
0answers
29 views

Magento Collection: can we set a query /w joins and all as collection/resource?

Magento Collection: can we set a query /w joins and all as collection/resource? We are creating a custom grid. And accessing a data collection query from different angles. In Model/Resource we ...
1
vote
0answers
288 views

How to filter catalogsearch result collection by custom conditions

I have some product in my magento store and want to filter catalogsearch result collection by some custom condition. I am using a extra field date in magento serach box and I have a custom attribute "...
1
vote
0answers
258 views

Upgrade from 1.9.2.4 to 1.9.3.1 results in no results on search Collection.php issue

I'm using the default Collection.php for search. With the new 1.9.3.1 the search bar for typing the search shows the search terms so it is clear it has results but then the results page says "Your ...
1
vote
0answers
1k views

Left layered navigation for the custom product collection in the custom page

I have a custom product collection (i.e) list of products which is based on the two attributes's values. Page is replicating the catalog page by the below xml <?xml version="1.0"?> <layout ...
1
vote
0answers
226 views

Magento 2 : How to implement Multi Select Category Filter?

I Have a category filter in my side bar , i managed to apply category filter using layred Navigation (using cat=11 in URL using a get method form) , now i want to add another category to the filter ...
1
vote
0answers
38 views

Output Array with Matching IDs

I have 2 collection (customer and subinfo) that pull info from 2 separate database table. both table information are related and i needed to join/merge the info, which i have done. but unfortunately ...
1
vote
0answers
153 views

Push an array of all sku's on a category page into my $data = array();

I want to list all sku's on a category page in a data array. Currently if i'm on a product detail page i can push the sku into my data array like this: if ($module === 'catalog' && $...
1
vote
0answers
180 views

Magento bestseller block method - where addCategoryFilter not working

we are creating a bestseller block and use the code below. We are facing two problems. One of which is that when I add a category filter then the method $collection->addCategoryFilter($category) ...
1
vote
0answers
107 views

Filter cms collection by store id before the store is saved

I have a custom module where an item (slider) has to be linked with a cms page. The website is multistore. So when the user inserts an item in my module I show a collection of cms pages where he can ...
1
vote
0answers
42 views

Code Review: Trying to get popular categories

On a main category page there is a section for "popular ranges" where a range is a different sub category. A simplified version of my category structure is: root |-Bathrooms |--Sinks |--Cabinets |-...
1
vote
0answers
106 views

List all customers with Magento collection resource iterator

I use resource iterator to loading large collections: $customers = Mage::getModel('customer/customer') ->getCollection() ->AddAttributeToSelect(array('...
1
vote
0answers
1k views

Filter a count column in a custom admin grid

I have an admin grid with a count column, everything works fine except the filtering. This is my _prepareCollection() method : protected function _prepareCollection() { $orders = ...
1
vote
0answers
565 views

How to use FIND_IN_SET on a multiselect attribute filter with an AND condition?

I have a product collection which is being filtered on a custom multiselect attribute called 'apartment_includes'. This is used on a site for people looking to rent a room for a short period of time. ...
1
vote
0answers
714 views

Trouble adding filter to product collection via observer

My goal is to filter the category product list by product's first letter. This works on my staging site by implementing the following: /app/code/local/Etre/Alphapagination/etc/config.xml <...
1
vote
0answers
129 views

Filtering product collection by combination of attributes

I have two sets of product attributes: Att1 {a, b, c, d} Att2 {e, f, g, h} These attributes are multiple select fields. Then I have a collection of 3 products: Prod1 (Att1: {b, d, a}, Att2: {g}) ...
1
vote
0answers
1k views

Chaining addExpressionAttributeToSelect calls

Currently my addExpressionAttributeToSelect method has nested expressions and I would like to make it more readable by splitting it into 2 or more addExpressionAttributeToSelect calls. Is it possible ...
0
votes
0answers
13 views

Difference between Magento Collection ,object , array

Please clear the main difference between Magento Collection , object , array and arraylist also ?
0
votes
0answers
16 views

How to get magento2 bundle products in list page

How to get magento2 bundle products in category list page. I assigned to category but not visible in frontend. Thanks
0
votes
0answers
11 views

Collection array attribute value change on run time

i have a collection [0] => Array ( [entity_id] => 93 [state] => complete [subtotal_invoiced] => 3445.0000 [total_invoiced] => ...
0
votes
0answers
22 views

Set a default filter for Order Grid

How can I set a default filter for Order Grid programmatically? I read many different answer but they don't work properly.
0
votes
0answers
19 views

Why product collection query not showing “color” attribute in select?

Case 1: $collection = $this->product->getCollection() ->addAttributeToSelect('color'); echo $collection->getSelect()->__toString(); Output: SELECT `e`.* FROM `...
0
votes
0answers
24 views

Call to a member function isLoaded() on array

Call to a member function isLoaded() on array in /var/www/html/codility-magento-market-place/vendor/magento/module-backend/Block/Widget/Grid/Extended.php:473 Stack trace $bestsalecollection = $this-&...
0
votes
0answers
13 views

Incorrect product sorting for numerical attributes (Magento 2.2.8)

I've got a shop with an attribute "capacity" created via Magento Backend: Shops -> Attribute -> Product It has "Text Field" as input type and "Decimal" as validation. So for new products therefore ...
0
votes
0answers
19 views

Set custom Record Count to Collection pagination in Report Grid

How we can set count of collection size before setting for the grid. Main Sales collection: $collection=Mage::getModel('sales/order')->getCollection() ->addAttributeToFilter('created_at', ...
0
votes
0answers
17 views

Magento 1.9.3.1 Sales Order Grid limit records

I have a Magento store running with over 18,000 order records all the other pages within admin load within 1 - 2 seconds apart from Sales>Orders this can take anything between 5 - 20 seconds to load. ...
0
votes
0answers
21 views

Magento 2.3 custom conditions for attribute filter using addAttributeToFilter

In Magento 2.3 I need to filter the collection as per below scenario. I have L, W and H attributes for products And user input is "X, Y and Z" then the following condition will give the desired ...
0
votes
0answers
21 views

Magento 2 how to match one item from one collection to another item in another collection if both are same then add to an array

I'm trying to compare two values from collection to another two values from another collection if they both are same then add that row to a array. How to achieve it. Can I get help? Thank you in ...
0
votes
0answers
302 views

Magento merge two collections with different sorting orders

I have one store in Magento 1.9 , There is a listing page with AJAX scroll loading, on first page I am showing 24 products. We are showing products with label In-Stock and Sold Out, In-stock products ...
0
votes
0answers
22 views

How to get all categories and products in one collection in magento 2

How to get all categories(with levels) and it's products in one collection in magento 2
0
votes
0answers
101 views

Magento 2.3 collection factory not exist

I use magento 2.3 and I can't see collectionFactory created in generated folder or inject to any class. ModelFactory can create normally. There are my code: Model file: <?php namespace Lights\...
0
votes
0answers
15 views

Set a permanent limit on returned rows in grid

I have created a grid extending Mage_Adminhtml_Block_Widget_Grid. Within _prepareCollection I'm doing this: $collection->getSelect()->limit(10); But as soon the reset filter button is clicked ...
0
votes
0answers
81 views

Best seller collection filter magento2

I am trying to filter Best seller product collection like below. Seems the setOrder is not working. class BestSeller extends \Magento\Framework\View\Element\Template { protected $...
0
votes
0answers
89 views

Magento 1.9.4 add custom dropdown field to inventory tab

Currently in magento when you manually change the quantity of a stock managed product in the admin there is no reason assigned to this. So, what I would like to do is add a dropdown field below the ...
0
votes
0answers
23 views

How can I use 0 instead of null magento 2 collection?

I have created module to show report in grid. But in collection some fields contains null value how can I change null to 0. <block class="Magento\Backend\Block\Widget\Grid\Column" name="...
0
votes
0answers
47 views

Magento 2 - Apply filter on Product collection

Is there any common event or plugin to apply the filter to product collection which includes product list page, related products list as well as upsell and cross-sell product list? If no, then how ...
0
votes
0answers
65 views

How to get a Array Response from collection with getfieldset

I'm trying to get a Array Response from collection with getfieldset like below, still got this error and unable to resolve this. Uncaught Error: Cannot instantiate interface Magento\Framework\DB\...