Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
2 votes
1 answer
76 views

Error while fetch data from db

I am Trying to fetch and filter data from database $collection = Mage::getModel('some/some')->getCollection()->addAttributeToFilter(something); but it give me an error Fatal error: Call to ...
Vaibhav Ahalpara's user avatar
3 votes
2 answers
2k views

What is different between getCollection(); and $product->getData();

What is different between getCollection(); and $product->getData(); $products_collection = Mage::getModel('catalog/product') **getCollection(); ->addAttributeToSelect('*') ->addFieldToFilter('...
Vaibhav Ahalpara's user avatar
2 votes
1 answer
10k views

How to add date filter to product collection

I was wondering if there is any way to add a date filter to a product collection. What i am trying to do: I have a collection for new products, i need to add a filter to it so it filter the products ...
Ylli's user avatar
  • 137
1 vote
1 answer
3k views

Magento using setCurPage for reviews pagination

I'm using the allreviews Magento extension so that I have a page with all reviews however I need to add pagination to this page. The last bit I'm stuck with is essentially adding the limit to the ...
Dan's user avatar
  • 143
3 votes
1 answer
2k views

Magento Sales quote collection error

I am getting sales quote collection with this reference,,but it throws below error. MyCode Mage::log($item_ids); $collection=Mage::getSingleton('sales/quote_item')->getCollection()->...
Manikandan Arunachalam's user avatar
7 votes
1 answer
4k views

Get item at nth index from a collection

Is there a way to get an item at the nth index from a collection without necessarily loop over all the collection?
giani.sim's user avatar
  • 1,473
1 vote
2 answers
2k views

How to select data from two table in magento with same condition in custom table

I have two table tbl_magazine, tbl_page .... I need to select data form magazine like... if magazine is enabled then also check magazine page is enable or not... if magazine is enable and some pages ...
user3623126's user avatar
2 votes
1 answer
166 views

Execute direct SQL

I am working on a reports module and I've noticed that running direct SQL queries is quite faster than using Magento methods for retrieving a collection. Is there any disadvantage to executing direct ...
LorenzoR's user avatar
  • 123
8 votes
2 answers
11k views

Check if product belongs to category?

I have a collection/array of ~4000 products(search results) and a category number and need to filter them. What would be the most efficient way of checking whether a product belongs to a certain ...
Alan's user avatar
  • 927
4 votes
1 answer
913 views

Zend > DB > Query > quote column

I've got a query which returns the orders by considering a condition on the column "maxvalue": Mage::getModel('sales/order')->getCollection()->addFieldToFilter('maxvalue', 'bla') It generates ...
Detzler's user avatar
  • 1,322
3 votes
1 answer
83 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')
user16992's user avatar
3 votes
1 answer
626 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 ...
user3726629's user avatar
1 vote
1 answer
785 views

addFieldToFilter in customer collection [duplicate]

I would like to add filters (with addFieldToFilter or other) in my customer collection Mage::getResourceModel('customer/customer_collection'). In sql it is: WHERE (billing_country_id = "FR" AND (...
mm232's user avatar
  • 11
1 vote
1 answer
1k views

Is website filter required if on collection is applied store filter

Is there any point of applying website filter after applied store filter already: $collection->addStoreFilter()->addWebsiteFilter(); will have same effect as: $collection->addStoreFilter(); ...
kanevbgbe's user avatar
  • 145
0 votes
1 answer
1k views

Setting cache lifetime on collections

I would like to know how we can control the cache lifetime on a collection. Here's how I initialize caching on my collection: public function _construct() { ... // Configure collection ...
Rick Buczynski's user avatar
1 vote
0 answers
92 views

Using group() in Magento EE with SOLR breaks pagination in Magento [closed]

When using GROUP BY (MySQL statement) on collections in Magento CE, we need to apply something similar to https://stackoverflow.com/questions/3485455/using-group-breaks-getselectcountsql-in-magento so ...
Ivan's user avatar
  • 11
1 vote
3 answers
4k views

How to filter product collection by price after tax?

I am trying to filter product collection by price range: $this->getLoadedProductCollection()->clear() ->addAttributeToFilter('price', array( 'lt' => 500 ) ) ->...
Alan's user avatar
  • 927
3 votes
1 answer
1k views

How to use addFieldToFilter() in field generated in sql?

If I try to filter a field in the existing table works, but a field generated by max () does not work, even renaming, display the error getBackend(). Examples: observer $collection->getSelect()-...
Dexxtz's user avatar
  • 574
2 votes
2 answers
2k views

Custom sales order report NOT matching Magento's sales order report

I'm building a custom report sales order using the following code as a start. I'm trying to get all orders that have been updated Yesterday, by passing filters from date and to date to sales/order ...
Aboodred1's user avatar
  • 483
1 vote
2 answers
149 views

What are the performance implications when loading collections in different ways?

Given two ways to loading a category collection: $children = Mage::getModel('catalog/category')->getCollection(); $children->addAttributeToSelect('name') ->addAttributeToFilter('...
CodeByMike's user avatar
1 vote
2 answers
9k views

Filters on custom product listing page not working

I have inherited a Magento job, in which they have a custom view for "brands". This basically filters the products based on a specific brand "code". However, the main problem is that this list of ...
Dan's user avatar
  • 63
0 votes
2 answers
657 views

Filter Products by Access Group

I try (for a special site) to filter the product collection by access group. The attribute is set in the backend by selecting one group or more, hence I have an array of the access group names ...
Awinad's user avatar
  • 31
5 votes
1 answer
25k views

Magento join collection query

I have this line: $collection->getSelect()->join( 'sales_flat_order_address', 'main_table.entity_id = sales_flat_order_address.parent_id', array('telephone','city','postcode','...
Somebody's user avatar
0 votes
1 answer
1k views

How to load product from multiple category in magento

I need to get a collection in magento by multiple categories but I am not getting any product when I add more categories. $products = Mage::getModel('catalog/category')->load(7,8) -...
dkstack Kumar's user avatar
0 votes
1 answer
784 views

Observe customer address save, update collection

I have a custom customer/address attribute gmap_lat which I would like to be included in the sales/order_address_collection. I would like to observe the customer_address_save_before event, but it ...
blisstdev's user avatar
  • 271
1 vote
1 answer
1k views

Join Customer Address custom attribute to Order Address Collection

I would like to join custom customer/address attributes with the sales_flat_order_address table and sales/order_address_collection resource model. The attributes are called gmap_lng and gmap_lat, ...
blisstdev's user avatar
  • 271
1 vote
1 answer
2k views

How to get sum of particular column (custom model)?

I have custom model with 4 fields(a,b,c,d). I need sum of "d" field. So my solution using collection loop the d values and make the sum.For this is any simple solution? Thanks in advance. $...
sivakumar's user avatar
  • 267
1 vote
1 answer
181 views

Sort a collection on a joined table

I'm making a module that to order reviews. In de mage-admin I added an extra field which gets saved into a new table review_featured On the product page I want to sort it based on the featured_number ...
janw's user avatar
  • 980
4 votes
2 answers
2k views

How to addFieldToFilter for attribute special_price with flat product tables?

In a class which extends Mage_Catalog_Model_Layer I have the following code: $collection = Mage::getModel('catalog/category') ->load($rootCategoryId) ->getProductCollection() ->...
Jey DWork's user avatar
  • 1,101
0 votes
1 answer
11k views

catalog_product_collection_load_before and getLoadedProductCollection

I have a strange problem, which gives me the feeling i missed some concept: In an observer triggered via event dispatch <catalog_product_collection_load_before> i fetch the collection and do a ...
Michael Leiss's user avatar
20 votes
4 answers
27k views

How can I fix "Item (Mage_Catalog_Model_Product) with the same id "xxx" already exist"?

I have been getting this error when trying to filter a products collection Item (Mage_Catalog_Model_Product) with the same id "6058" already exist and wanted to ask what could ne causing the error ...
user1704524's user avatar
  • 2,483
5 votes
2 answers
3k views

Load visible and invisible products at once?

This is my code: $visibility = array( Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, ...
user1638055's user avatar
13 votes
1 answer
32k views

How to use group by in magento collection with join query

In module's admin grid I am using this code to get collection and group them by customer id $collection = Mage::getModel('referafriend/statistics')->getCollection(); $collection->getSelect()-&...
Haris's user avatar
  • 869
1 vote
2 answers
5k views

getCollection returns active products without status filter

I am getting product collection without using addAttributeToFilter('status',array('eq'=>,1)),but still my collection has only active products. Why it returns active products default?Is there any ...
Manikandan Arunachalam's user avatar
0 votes
1 answer
960 views

Change sort order for bundle selected product by name magento

I want to sort magento bundle product selected sort order on magento admin.i have changed below code file but nothing happen.i don't know from where it collect collection of product so i can set order....
Zahirabbas's user avatar
  • 2,073
2 votes
2 answers
9k views

magento show product collection by id

I want to show some specific product on product listing page : like product_collection.phtml there is a code that grab the collection $_productCollection=$this->getLoadedProductCollection(); ...
mcoder's user avatar
  • 713
1 vote
2 answers
6k views

Layered Navigation: Price filter on custom collection

I have a category which uses a custom product collection and layered navigation. Everthing is working fine except the price filter (Magento 1.9). It displays the correct price ranges, but does not ...
Socrates's user avatar
  • 175
0 votes
1 answer
359 views

Filtering Custom Options Collection

Given a collection obtained by (this is Magento 1.4): $collection = Mage::getModel('catalog/product_option') ->getProductOptionCollection($_product); This returns the collection of options ...
pspahn's user avatar
  • 4,648
0 votes
2 answers
1k views

Filter out of stock item in listing page using Event even if it is Display Out of Stock Products to yes ?

I have the situation to filter product who is having Stock Availability as 'out of stock' in product listing page. Need to show only in product detail page. I tried with following event in my custom ...
mymotherland's user avatar
1 vote
1 answer
264 views

Autocomplete city from database

I want to create an autocomplete input for city in onepagecheckout, and registration form. I've a database table with all my data and I've a function php tha give me the json that look like this [{"...
Marco's user avatar
  • 85
0 votes
1 answer
2k views

Product collection for subcategories of subcategories

I have the following menu/category structure in my store: root | products | | | cars bikes vans | | | bmw carrera fiat audi apollo ...
odd_duck's user avatar
  • 1,396
0 votes
1 answer
145 views

Simple query: group by customer & specific product attribute (shirt size) but how?

we sell shirts. Now I would like to create quick query that results in the following customer id | name | email | shirt size (grouped) I think we can get the orders through collection sales/...
snh_nl's user avatar
  • 5,442
0 votes
2 answers
119 views

Magento Product Ranges

Is there any way in Magento to set up product ranges or collections? For example, if my store sells clothing such as coats, jackets and shoes and I launch an Autumn range, is there a way to see ...
Pabzoid's user avatar
  • 93
0 votes
1 answer
495 views

Better query to delete object inside a collection

I'm trying to delete a wishlist item from the collection, the code works, but whats a better way instead of using the naive forloop $wishlist_collection = Mage::getModel('wishlist/item')->...
Yehia A.Salam's user avatar
1 vote
1 answer
11k views

Filter Collection By Multiple Values From Multiselect Attirbute Using addFieldToFilter() Method

I am currently developing a banner manager module that allows the admin to upload banners and select which store views those banners will appear on. I have everything working fine when a single store ...
Ryan's user avatar
  • 33

1
26 27
28
29 30
34