3

What is the use of getJsonConfig() method? What does this method do? What is the meaning of the below line in view.phtml

var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);

3 Answers 3

5

The getJsonConfig of the product block returns the js configuration for product price changing.
It returns different values depending on product type (simple, configurable, bundle) or if it has options or not, and depending on the tax settings.
The json it returns is then picked up buy the OptionsPrice js "class" in varien/js/product.js and changes the price in the browser depending on your selections.
For example, when you select an option for a configurable product, the price is changed accordingly. The same thing happens when you change a bundle product options.

2

by $this->getJsonConfig()

$this refer to block which you have define in layout

If you see in app/design/frontend/rwd/default/layout/catalog.xml file

between <catalog_product_view /> tag you will find below code

<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">

So in view.phtml $this refer block

app/code/core/Mage/Catalog/Block/Product/View.php

you can find public function getJsonConfig() there

this will create a product price json as you see in function getJsonConfig() will create json including tire price and all

1

$this->getJsonConfig() The method is part of

class Mage_Catalog_Block_Product_View

/**
     * Get JSON encoded configuration array which can be used for JS dynamic
     * price calculation depending on product options
     *
     * @return string
     */
    public function getJsonConfig()
    {

    }

  */
1
  • can you please explain me What is the use of this method?
    – Ramya
    Commented Jul 18, 2016 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.