We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
2
votes
1answer
4k views

Downloading order details through Mage::getModel('sales/order')

I am trying to download order details (email + name) from my stores. We have a multi-store. The problem that I have is that when I run this code on STORE 1 or STORE 2 - both result in the full ...
29
votes
1answer
27k views

About Collection Model and Resource Model

I am bit confused about using resource model and collection model. Sometimes when I see examples for loading products using specific attributes, in some examples, they use collection model and ...
0
votes
1answer
326 views

Add a product collection to customer entity type

I would like to allow a logged in user to select his or her favorite products. This list should be maintained from a new account page to be created following Alan Storm his article: http://alanstorm....
2
votes
1answer
771 views

Error using a custom collection for a report

this is a hard question to ask but I am trying to write a reporting module, following: http://www.summasolutions.net/blogposts/custom-reports-magento. I got that module to work on my install, but ...
1
vote
1answer
400 views

How Do I Create a Derived Collection

I am trying to follow what "uguptu" is recommending here: http://www.magentocommerce.com/boards/viewthread/225234/ In particular, I am trying to run my own highly specific query on the sales/order ...
16
votes
4answers
18k views

Add Column to a grid (observer) - Column ‘store_id’ in where clause is ambiguous issue

I'm adding a column to the order grid using observer approach: On the event -> sales_order_grid_collection_load_before I'm adding a join to the collection On the event -> ...
82
votes
6answers
70k views

Difference between getSize() and count() on collection

I have heard many times that they both are the same. But I am facing a weird issue, in the product collection of CatalogSearch module, count() is returning correct product count while getSize() is ...
12
votes
2answers
6k views

How to clone the collection in Magento?

I have one collection in a method where I want to perform two different operations on this collection. So, I want two separate copies of same collection, and then assign one of the two collections to ...
2
votes
3answers
4k views

Best Practice: How to add a column to a backend grid ?

Usually we need to add to the Order Grid some column, so let take this as example. There are 3 ways to do that: Rewrite the grid block in our custom module Use an observer on the event ...
6
votes
3answers
2k views

Product load event - regardless of context

Is there a single event that I can create an observer for that gets fired when a product is loaded either using getModel or through a collection? The exact use case i have is that i have a custom ...
1
vote
2answers
5k views

Magento Error: Item (Mage_Sales_Model_Order) with the same id “1457” already exist

$items = Mage::getModel('sales/order')->getCollection(); $items->getSelect()->joinLeft('sales_flat_order_item', 'main_table.entity_id = sales_flat_order_item.order_id', array('name')...
1
vote
2answers
3k views

How to sort special price collection

I have a page with promotions based on set special price from/to date attribute and it shos fine. I have created a new attribute called flash that is a yes/no value. I want to order the previous ...
2
votes
3answers
17k views

Magento - Get Products from Specific Category

I am currently using the following code to display four products in a random order. It works, but I'd like to limit the results to a particular category or an array of categories. How would I go about ...
7
votes
3answers
9k views

Four Random Products on Homepage

I'm trying to get 4 random products on the homepage using PHP within a TPL file I've created. I'd like to be able to format the products in a foreach loop as I'm using some formatting in the code seen ...
1
vote
4answers
11k views

Filter collection by existence of attribute

I'm working on an e-commerce site populated with products that depend heavily upon having well-populated spec sheets. Unfortunately quite a few of the products are somewhat less complete than I'd ...
1
vote
2answers
8k views

Can I override getLoadedProductCollection() before it’s being loaded?

I'm trying to override the products collection that's coming from $this->getLoadedProductCollection() so I tried to override the method class **_**_Model_Rewrite_Layer extends ...
1
vote
1answer
2k views

Magento - Special Collection not showing toolbar and breaking sidebar on single product view

I have a magento store that needs to have two pages that show both the new products added to the store and the ones that are on a discount. Both show the same issue but I'll give you the code for the ...
0
votes
2answers
1k views

Trouble while getting product collection in observer

i am trying building a small module which house a Observer for getting called when and event called when catalog_product_import_profile_after is fired this is custom event which i have fired using the ...
21
votes
2answers
10k views

Is it possible to iterate over Magento collections with pagination natively?

What I mean by that is - is there a way to do: $collection = $model->getCollection(); foreach ($collection as $item) { $item->doStuff(); } In such a way that even if the collection had ...
4
votes
2answers
3k views

Joining to a Resource Model that doesn't have a Select?

So I have this resource model that I pulled from some admin code on the dashboard. It works, but I can't seem to join to it. Doing ->getSelect()->__toString(); shows nothing? So is this not a ...
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 ...
14
votes
5answers
14k views

Filter product collection by non-flat attribute

I am doing the following: $productCollection = Mage::getModel('catalog/product') ->getCollection(); $productCollection ->addAttributeToFilter('my_attribute', 1); my_attribute is not ...
1
vote
1answer
3k views

How to sort child category collection

I a m using this function for getting child categories of current category public function getCurrentChildCategories() { $layer = Mage::getSingleton('catalog/layer'); $...
5
votes
1answer
2k views

FishPig Attribute Splash Pages Extension Bugs [closed]

I'm evaluating the FishPig Attribute Splash Pages extension for a client, and I've run into a few bugs. I've got support requests into the extension vendor, but since it's a free extension I figured ...
4
votes
1answer
3k views

Getting Customer Collection

How do I add company and group name to this collection $collection = Mage::getResourceModel('customer/customer_collection') ->addAttributeToSelect('*') ...
2
votes
6answers
3k views

Attribute is not loaded on Product_List and Layered Navigation

I have a development system, here is everything working as expected. And I have a staging system, here the attribute is not loaded. It feels like, the sytem don't know, that the attribute doesn't ...
4
votes
2answers
2k views

Add all flat-attributes to product collection?

How can I get a catalog/product collection with all attributes which are selected to be "used in product listing", i.e. are in the flat table?
4
votes
2answers
10k views

Product Attributes and filtering mechanics

TL;DR: How to filter multiple select/dropdown attributes (multi-selects would be cumbersome)? Or use a different method? Consider a product select/dropdown attribute whose values correspond to each ...
3
votes
1answer
3k views

Filtering error when using custom Varien object collection in admin grid

I have created a custom Varien object collection for my admin module (because the data is not from a db) and have got it successfully to show in an admin grid. I built the collection by using the ...