Question

I see the '{{pricing_value}}' in /app/design/adminhtml/default/default/template/catalog/product/edit/super/config.phtml, I guess that it is a template engine expression, but not sure. What's it?

How does it get value? From the block Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config?

If I want to process it's value, where should I go to edit? '{{pricing_value}}' will show null when pricing_value set 0, but I want it just to show 0. At the same time, when I leave it blank, it still blank.

Was it helpful?

Solution

Here is what you can do, Open product.js file, go to line around 671

Replace below code

if (!isNaN(pricingValue)) {
    templateVariables.set('pricing_value', pricingValue);
} else {
    templateVariables.unset('pricing_value');
}

with

if (!isNaN(pricingValue)) {
    templateVariables.set('pricing_value', pricingValue);
} else {
    templateVariables.set('pricing_value', 0);
}

Refresh your cache and check.

EDIT

To achieve what you require, there is a weird solution. Undo the changes stated in above code. Now when you add the price for a product attribute in product section use 0.00 as value instead of 0 where you want to add 0 price and leave blank where you want to leave blank.

It seems weird but works with minimal effort and without core changes.

OTHER TIPS

'{{pricing_value}}' is a templating variables, Magento has parser to recognize the codes and transform them into actions. You can assign variables to Magento, then using the double curly brackets syntax to retieve them, it often appears in email templates, invoices templates, etc. Some detail example you could see below:

Magento - how to add custom variables to new order E-mail?

Advanced Transactional Email Templates


The processing of '{{pricing_value}}' is in /js/mage/adminhtml/product.js:

var pricingValue = parseFloat(templateVariables.get('pricing_value'));
if (!isNaN(pricingValue)) {
    templateVariables.set('pricing_value', pricingValue);
} else {
    templateVariables.unset('pricing_value');
}

When pricing_value is 0, Magento doesn't save it to table catalog_product_super_attribute_pricing, so pricingValue(0) is always get null, that is to say, pricingValue(0) is always NaN and like blank. So if you want

when I set input 0, it is 0. When I leave it blank, it still blank

You should not set input 0, but set input 0.0 according to the answer of Jaimin, then 0.0000 will be saved to the table and work as you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top