Removing Currency Symbols from Bundled Product Prices in Magento
In Magento, bundled products allow customers to purchase multiple items together with discounted prices. However, you might find that the currency symbol appears incorrectly on the bundled product page for certain items. This guide will walk you through how to remove the currency symbol from the final price of a specific bundled product.
Why Currency Symbols Appear Incorrectly
The issue arises due to Magento’s default pricing logic for bundled products. By default, Magento displays the total price with a currency symbol, even if individual items within the bundle do not include one. This isn’t always desirable, especially when dealing with external systems or specific product types.
Solution: Override the Price Rendering Method
To resolve this issue, we need to override the _toHtml() method of the Mage_Catalog_Block_Product_Price block for the target bundled product.
- Create a Custom Module
First, create a custom Magento module in your app/code/local directory:
app/code/local/YourCompany/BundlePrice
- Override the Price Block
Inside the BundlePrice module, navigate to:
app/code/local/YourCompany/BundlePrice/Block/Product/Price.php
Create the file and add the following content:
<?php
class YourCompany_BundlePrice_Block_Product_Price extends Mage_Catalog_Block_Product_Price {
public function _toHtml() {
$product = $this->getProduct();
if ($product->getTypeId() == 'bundle' && $product->getSku() === 'your_bundled_product_sku') {
return parent::_toHtml();
}
// Remove currency symbol for non-target bundled products
$price = $this->getPrice();
$price->setDisplayValue(str_replace($this->getCurrency()->getSymbol(), '', $price->getDisplayValue()));
return parent::_toHtml();
}
}
Replace 'your_bundled_product_sku' with the actual SKU of your target bundled product.
- Configure the Module
Create a config.xml file in:
app/code/local/YourCompany/BundlePrice/etc/config.xml
Add the following content to tell Magento where to find our custom price block:
<config>
<global>
<blocks>
<catalog>
<rewrite>
<product_price>YourCompany_BundlePrice_Block_Product_Price</product_price>
</rewrite>
</catalog>
</blocks>
</global>
</config>
- Clear Magento Cache
After creating the module and files, clear your Magento cache:
php shell/indexer.php reindexall
rm -rf var/cache/*
rm -rf var/session/*
- Test the Changes
Visit your front-end and navigate to the bundled product page containing the target SKU. You should now see that the currency symbol is removed from the final price of the specific bundle you targeted.
Conclusion: Achieving Currency Symbol Removal
By following this method, you can easily remove the currency symbol from the final price of a specific bundled product in Magento without affecting other products or modules. This approach involves creating a custom module to override the default price rendering logic specifically for your target SKU.
Remember, always backup your files before making changes in a live environment. If you find yourself struggling with this process or need further assistance with Magento development, feel free to explore our Magento Development Services at Laravel Company.
This method ensures that only the final price of your targeted bundled product is displayed without the currency symbol, maintaining a cleaner and more consistent front-end experience for your customers.