Questions tagged [collection]

Questions related to Magento collections

299 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
0answers
90 views

Missing eav attribute options in collection

I miss some custom attribute options in my collection. I'm using the standard "\Mage_Catalog_Model_Product_Type_Grouped::getAssociatedProducts" method. When I debug the collection inside that method ...
1
vote
0answers
143 views

Problem in creating custom reports for inventory forecasting

I have followed this https://magento.stackexchange.com/a/14783/34850 & copied as it is & then made several changes like name space, grid(columns/field names) & query but somehow not ...
1
vote
1answer
385 views

Magento2 does n't get the order collection from Order\CollectionFactory

I am using the Magento2.2 version . I am using the class Magento\Sales\Model\ResourceModel\Order\CollectionFactory; to get the order collection.But getting the error Fatal error: Uncaught Error: ...
1
vote
0answers
374 views

How to Filter Attribute Set, Attribute option value and filter by manufacture in product export

Change into app/code/local/Mage/ImportExport/Model/Export/Entity/Product.php on line 647 in funtion export() $collection = $this->_prepareEntityCollection(Mage::getResourceModel('catalog/...
1
vote
0answers
171 views

Incorrect product count in layered navigation filter while sort using custom collection

I have an issue with layered navigation filter count. I have changed the product collection of sort, everything is working fine except the product count. Can anyone help. Toolbar.php class ...
1
vote
0answers
206 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
1answer
311 views

Magento 2.2 product collection doesn't return out of stock products

Magento 2.2.* seems to make it very difficult to get out of stock products in a collection! I have the following code which works fine in Magento 2.0 and 2.1: use Magento\Framework\View\Result\...
1
vote
1answer
998 views

Magento 2.2 : Search Functionality/Layered Navigation on a Custom Product Collection?

I use a custom product collection which is used on all category view pages (basically, instead of using Magento's collection, I wrote my own module with the custom collection to implement a cookie-...
1
vote
0answers
91 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
1answer
560 views

How to check the category collection is empty or not in magento 2?

I am getting the subcategories of a main category like this(this file is in root folder) use \Magento\Framework\App\Bootstrap; include('app/bootstrap.php'); $bootstrap = Bootstrap::create(BP, $...
1
vote
0answers
139 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
106 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
436 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
368 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
1answer
499 views

Add category IDs to product collection

I am injecting this collection into my model: \Magento\Reports\Model\ResourceModel\Product\Collection $prodCollection I use it to create an array of all products but I want to add the products ...
1
vote
1answer
174 views

Fetch a specific model in magento 2

I have 2 ways to fetch a model object: $orderId = 18; /** @var \Magento\Sales\Model\Order $firstOrder */ $firstOrder = $this->_orderFactory->create()->load( $orderId); /** @var \Magento\...
1
vote
1answer
41 views

How to bring all customer attributes on CatalogRule?

I have requirement to show all customer attributes on Catalog price Rule Form. You can see attached image for more clarity. How i can get customer attribute collection and how i can display in ...
1
vote
1answer
956 views

Magento-2 How to get custom product collection in catalog search result based on particular category

I am working on custom module for catalog access. It requires only logged in customer to access the assigned category products. Right now in catalog search result, product collection displays all the ...
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
92 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
255 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
1answer
140 views

How SELECT `e`.* is coming in Query while printing collection filter in magento 1.9

$collection = Mage::getModel("customer/customer")->getCollection() ->addAttributeToSelect('firstname') ->addAttributeToFilter('grisk_college_new_id', array('in' =>...
1
vote
0answers
365 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
2answers
228 views

How to count only enabled product from product_link collection

I've found in a template file, a code like the one below: $collection = Mage::getModel('catalog/product_link') ->getCollection() ->addFieldToFilter('product_id', $...
1
vote
1answer
249 views

How to display ONLY products which associated products are in stock with custom collection

I'm having a hard time on how to display those configurable products which associated products are in stock only. For example, if I have a configurable product and the quantity stock status of its ...
1
vote
1answer
126 views

how do i get controller value to template file

I am going to create reward point extension in which the calculation of grand total are in my module controller and now I want to show the final value at the place of grand total for that I want to ...
1
vote
0answers
177 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
65 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
1answer
440 views

How to add product attributes at admin dashboard bestsellers tab?

I would like to know, how to add product attributes ie SKU, Color, Size at admin dashboard bestsellers tab? app\code\core\Mage\Adminhtml\Block\Dashboard\Tab\Products\Ordered.php Collection Code: $...
1
vote
1answer
883 views

How to get all products collection for special category

I am looking for function which is similar to getLoadedProductCollection and which retrieves all products from this category with selected filters, not only those I can see on current page like ...
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
263 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
1answer
508 views

Exclude products with category id - productCollection

I am currently trying to run a productCollection to try and get a list of products that are not assigned to one or more categories. $collection = Mage::getResourceModel('catalog/product_collection'); ...
1
vote
0answers
234 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
41 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
1answer
416 views

Magento 2.1 - Get a collection including out of stock products

In a basic block I'm getting the featured products, however I only get the products that are in stock: public function getProducts() { $collection = $this->_productCollectionFactory->create(...
1
vote
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 ...
1
vote
2answers
274 views

Custom Attribute no longer available in the TopMenu since Magento 2.1

In a Module I configured my custom attribute redirect_url for categories to be included in the collection using catalog_attributes.xml This seems to no longer work in Magento 2.1 My module defines ...
1
vote
1answer
282 views

Magento2: How can I fetch the email transaction grid collection in my custom extension?

I am working on one custom module and I need to fetch the transactional email templates grid which is at Marketing > email templates in magento 2 default. I need that grid in my custom extension, how ...
1
vote
1answer
582 views

Get ordered product size and color in order items admin grid in Magento 1.9.2

I am showing a list of items ordered from all the orders from 'sales_flat_order_item' table in Magento 1.9.2 . I get the name ,Sku and all other values from the following collection. protected ...
1
vote
4answers
4k views

Magento 2: How to set visibility and status to product using collection?

I'm creating a cron to pass through all the products and set them visible and active. This is my execute of the cron who runs well: public function execute(){ /** * @var $item \Magento\...
1
vote
0answers
161 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
1answer
157 views

magento bestseller block: product collection contains only old hardly ever sold products

We are creating a bestseller block and use the code below. With the code below we get a nice list of products. The only problem is that many of these products are either very old - and hardly ever ...
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
109 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
43 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
108 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
1answer
957 views

Magento2 how to override collection

I've just been working with Magento2 for 1 week. There are many things that made me confuse. I want to build a grid that show information from "directory_country_region" table but show only for "...