How to get product price filter by store

How to get product price filter by store

October 5, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to get product price filter by store

Getting Product Prices by Store ID in Magento

If you’re trying to retrieve product prices based on a specific store ID in Magento, you might be running into issues with the default price being returned instead of the store-specific one. Let’s dive into why this happens and how to correctly fetch product prices by store.

Understanding Magento’s Store View Configuration

In Magento, each store can have its own configuration for product prices through the “Use Default Value” checkbox on the Price scope filter in the backend. If this is checked, the default price will be used regardless of the store view selected.

The Issue with Your Current Code

The issue lies in how you’re adding a store filter to your collection. The addStoreFilter method only filters products that have special prices assigned to the specific store view. However, it doesn’t ensure that the regular price returned is from the desired store.

Here’s what happens in your current code:

  1. You fetch all products using the default scope.
  2. You apply a store filter, which only includes products with special prices for that store.
  3. The getPrice() method subsequently returns the default price because you haven’t explicitly requested the price from the filtered store.

Correcting the Product Price Retrieval

To correctly retrieve product prices by store ID, you’ll need to use the getPrice method with the appropriate scope configuration. Here’s how:

$store_id = 2;
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect(array('name', 'image', 'price', 'special_price', 'special_packing', 'prosort', 'description', 'special_from_date', 'special_to_date'))
    ->addStoreFilter($store_id)
    ->addAttributeToSort('position');

Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

foreach ($collection as $product) {
    $products = Mage::getModel('catalog/product')->load($product->getId());
    echo 'Product ID: ' . $products->getId() . ', Price from Store 2: ' . $products->getPrice();
}

Fetching Prices with the Correct Scope

The key change is in how we’re fetching the price. Instead of just calling getPrice(), we need to explicitly set the store before getting it:

$store = Mage::app()->getStore($store_id);
$this->setStoreId($store->getId());

This ensures that when you call getPrice() or any other price-related method, Magento will return the value from the specified store’s configuration.

Conclusion

Retrieving product prices by store ID in Magento requires a proper understanding of how stores and their configurations work within the system. By correctly applying store filters to your collections and setting the appropriate scope before fetching prices, you can ensure that the returned values match the desired store view’s settings.

Remember to review and update your configuration in the backend if needed, as the “Use Default Value” checkbox for price scopes can sometimes cause unexpected results. This approach should help you accurately fetch and display product prices for different stores within your Magento installation.

For a more in-depth exploration of Magento development best practices and other helpful resources, be sure to check out our blog at https://laravelcompany.com.

Catalog Themes Admin Configuration

Our network