Magento filter product collection by tier price for current customer group

Magento filter product collection by tier price for current customer group

September 20, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento filter product collection by tier price for current customer group

Filtering Magento Product Collections by Tier Price for Current Customer Group

In Magento, filtering products based on tier prices for the current customer group is a common requirement for implementing pricing rules or availability restrictions. To achieve this, you’ll need to join the catalog_product_entity_tier_price table with your product collection and filter based on the presence of a row for the current customer group.

Step 1: Establish the Product Collection

First, create an instance of Magento’s Zend_Db_Table_Abstract class for the catalog_product_entity_tier_price table:

$tierPriceCollection = Mage::getModel('core/resource')->getConnection('core_read')
    ->select()
    ->from(array('tpe' => 'catalog_product_entity_tier_price'));

Step 2: Join with the Product Collection

Next, join this selection with your product collection. For simplicity, let’s assume you already have a standard Magento Mage_Catalog_Model_Resource_Product_Collection:

$productCollection = Mage::getModel('catalog/product')->getCollection();

$collection = $productCollection->join($tierPriceCollection,
    'main_table.entity_id = tpe.product_id',
    array('*'),
    null, 'left');

Step 3: Filter by Customer Group

Now that we have the joined collection, filter it based on whether a row exists for the current customer group:

$currentGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();

$collection->addFieldToFilter(
    array('tpe.customer_group_id'),
    array(array('null' => false), array('finset' => $currentGroupId))
);

Step 4: Fetch the Filtered Products

Finally, fetch the filtered products and proceed with your logic:

$filteredProducts = $collection->getItems();
foreach ($filteredProducts as $product) {
    // Process each filtered product here
}

This code demonstrates how to create a collection of products that only includes those for which a tier price has been set for the current customer group. If no row exists in catalog_product_entity_tier_price for a given product and customer group, the product will be excluded from the final list.

Conclusion

In summary, filtering Magento product collections by tier prices involves joining your product collection with the relevant tier price table and applying a filter based on whether a row exists for the current customer group. This approach ensures that only products that meet the specified pricing criteria are included in your output or further processing logic.

Remember to replace Mage references with their equivalent classes if you’re working with Magento 2, and ensure you have the necessary permissions to access the required data tables.

For more advanced Magento customizations and best practices, consider consulting professional resources like Laravel Company, which offers expert guidance on eCommerce development and optimization.

Catalog Database API Customers

Our network