Questions tagged [product-collection]

Questions related to Magento product collections.

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

Get collection with ordered quantities for admin grid

I added a custom grid in admin panel which shows all the Best seller product collections. (configurable products). The admin grid has the following columns: entity_id product_name sku ...
1
vote
1answer
95 views

Keep the collection always fixed to certain number

I am using the following code to get five Best sellers collection. The number five is fixed here. // Array of Id's to retrieve from product collection $dataArray = array(2, 8 , 17, 3, 7); $...
4
votes
2answers
616 views

Show previous and next link in link tags under head in category page

In category page, I need to show link tags that holds pagination's previous and next links like below: <link rel="prev" href="http://www.test.com/prod1.html?p=1" /> <link rel="next" href="...
1
vote
2answers
3k views

Translate direct SQL query into collection model usage

I've got this query: SELECT * FROM 'catalog_category_product' WHERE 'product_id' IN ('.$IDs.') where $IDs I get the following way: $IDs = implode(',', $products); and $products is an array of ...
0
votes
1answer
947 views

Load only certain attributes and map them, by collection

So I am using this code: $connection = Mage::getSingleton('core/resource')->getConnection('core_read'); $IDs = implode(',', $products); $sql = 'SELECT * FROM `catalog_category_product` WHERE ...
1
vote
1answer
2k views

How can products with images be displayed first in category or filter for an entire collection? (list.phtml)

Magento store owners with thousands of products will no doubt have difficulty getting images and descriptions for every single product. To try and overcome this myself, I found some code that would ...
7
votes
3answers
29k views

Get Product Collection Containing In-Stock Products Only

There may be a simple answer to this, but I can't find it. I'm trying to retrieve a product collection, excluding products that are enabled, but out of stock. I've tried the following approach, but ...
0
votes
2answers
1k views

To get product collections by some range of ids in magento

I want to update all product price by specific percentage from current price.I got the following line of code update price by percentage wise $products = Mage::getModel('catalog/product')->...
0
votes
1answer
3k views

How to group products by attribute in product list?

Is there a way to display products of category so that products are grouped by an attribute? For example if we have a car parts shop and we want to display all parts that belong to certain car model ...
0
votes
1answer
3k views

Get color values used in products

Goal: I need to display on homepage a list of colors of products available at the moment in the particular store view. Description: Products have color attribute (the default attribute which exists ...
2
votes
1answer
644 views

Upsell Products not visible if it's category and products category are different

Hi i'm having below categories Camera - DSLR - Digital Camers Accessories - Lenses - Memory cards I've added a product from lenses category as a upsell to a product from Digital cameras. but it'...
1
vote
3answers
3k views

Getting the product collection from an advanced search

I'm trying to get the product collection containing only the products that appear in a search, from inside app\design\frontend[theme]\catalog\layer\view.phtml I've tried: $search = Mage::...
1
vote
2answers
1k views

Magento get product collection via custom observer

I have a custom observer in Magento 1.8.1.0 that is called on Product view page when current product having any upsell products. I have verified (using Mage::log()) that the observer is working, ...
2
votes
3answers
1k views

how to hide a product programmatically on frontend without disabling it, using an event or overriding core classes?

I'm trying to "hide" a product for a specific country without disabling it from the store. For now i used two events one is for updating collection on product listing using event (...
3
votes
2answers
20k views

Limit Product collection

a have a question to some basic stuff of filtering and limiting product collections. I searched the web for the solution but nothing worked. I hope to get some help here. So, the task is to limit the ...
1
vote
1answer
2k views

Weird "1103 Incorrect table name" error

The code: public function testAction(){ $Collection = Mage::getModel('catalog/product')->getCollection(); $Collection->getSelect()->join(array('t2' => 'SELECT ...
1
vote
1answer
1k views

Problem with product collection and configurable products

Hi i have this code: //shop the look product code $products = Mage::getResourceModel('catalog/product_collection'); // Select which fields to load ...
4
votes
1answer
3k views

Custom sorting for product collection

I have to implement the following scenario. The default sort order in category (by position) should ignore the position set for the products in the category. Instead when sorting by position it should ...
10
votes
1answer
18k views

Collection with FIND_IN_SET on multiselect attributes, but some has only one value

I am building a product collection, which will find results from a multiselect attribute. (relevant code that adds finset to collection - adjusted to display real id values) $attribute = Mage::...
0
votes
1answer
102 views

Change the way of price filter applied

I have a custom stock status attribute with 4 options. array( 4 => 'In Stock', 3 => 'Soon', 2 => 'Out Of Stock', 1 => 'Discontinued', ); I want change the way of price ...
1
vote
1answer
2k views

get category name from products 'reports/product_collection'

I've to list the best selling products and their category name. For this I'd used $_storeId = Mage::app()->getStore()->getId(); $_products = Mage::getResourceModel('reports/product_collection') ...
0
votes
2answers
2k views

Sort Product Collection by custom integer attribute

I created a custom_stock_status attribute in my module with 'int' backend type and four options in resource. array( 4 => 'In Stock', 3 => 'Soon', 2 => 'Out Of Stock', 1 => 'Discontinued', ...
0
votes
1answer
1k views

Work with custom product attribute without loading the product object itself

I need to manipulate a custom product attribute for almost all products in the database. Right now I have this: $productsCollection = Mage::getModel('catalog/product')->getCollection(); ...
1
vote
1answer
220 views

Products Sold Collection

I'm creating a custom Grid in Adminhtml which is to list all of the items sold in the past 30 days. I have the Grid setup, with basic product data being filled. However, I need data such as current ...
3
votes
1answer
8k views

How to get dropdown (and multiple) select value for a product collection?

In Magento 1.5 on the product page, I created a product collection (for related products) like this (I've omitted filters): // $_products = Mage::getResourceModel('catalog/product_collection') // ...
1
vote
1answer
525 views

If catalog flat product is enabled topsellers collection no image,name,price!

Hi i need to enable catalog flat product to boost magento but i have big problem with magento collection. If $visibility is enabled it will crash with 4 Unknown column 'e.visibility' in 'where clause' ...
2
votes
1answer
370 views

Collection pagination skipping records

I'm having trouble with Magento's built-in collection paging skipping over many records. I am attempting to optimize a product feed generator that dumps a bunch of product data to a file, and have ...
13
votes
4answers
21k views

How to filter products NOT IN categories?

Here is my code: $catIds = array(7,8,9); $collection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect("*"); ->addAttributeToFilter('category_ids', array('...
0
votes
1answer
2k views

Random product collection, getPriceHTML gives wrong values

I am creating a random list of products that refreshes every hour. I've got most of it done but there is one problem: getPriceHTML is returning NULL. This function is used in the normal category ...
2
votes
1answer
223 views

Product Collection Takes too much time

I have the following code. $collection = Mage::getModel('catalog/product')->getCollection(); $collection->addAttributeToSelect(array('featuredcategory','featured', 'price','name'...
2
votes
3answers
8k views

How to get all image urls in product collection? How to apply group_concat here?

I'm trying to get product collection with all of its images url. Is there any other way to get product collection with all of it image urls? $collection = Mage::getResourceModel('catalog/...
1
vote
1answer
5k views

addFieldToFilter not returning attribute values

I have a product attribute called remote_image_link. When I retrieve a product using this code: $mageProduct = Mage::getModel('catalog/product') ->getCollection() -&...
2
votes
1answer
130 views

sort by new in magento 1.7.0.2 ce as default for category page

We can't manage to sort by new as default in the category product list. This does only work when we set the order option in the category back-end, but due to our large category three we can't do this ...
2
votes
2answers
3k views

Is it possible to sort the product collection based on another array that contains skus

I have an array that contains some SKUs belonging to the current category. I want to reorder the collection based on that array so that the SKUs present in my order array will come first. For this i ...
7
votes
2answers
2k views

Filter Product Collection By Another Attribute In Product Collection eg 'attribX', array('gt' => 'attrib-Y')

When using product collections like so: $_productCollection= Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('*') ->...
2
votes
1answer
389 views

Search result display

I am trying to display the search result sorted by attribute_set_id. I want to display them with the title as the name of the first attribute_set and then all the products that belong to ...
0
votes
1answer
5k views

Bundle products not saleable when all associated products are out of stock?

By default Magento indicates a bundled product out of stock if none of the associated products are in stock. Is there a way to change that behaviour? I'm not using any isSaleable() conditionals, so ...
18
votes
7answers
104k views

Get product collection from a category id

I am trying to get a collection of products from a category id. A few things I have tried are in the block : $category = Mage::getModel('catalog/category')->load(123) ->...
7
votes
3answers
10k 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
10 11 12 13
14