Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
73
rated 0 times [  75] [ 2]  / answers: 1 / hits: 5060  / 10 Years ago, wed, april 9, 2014, 12:00:00

I need to make some changes to the following Magento files:




  • public_htmljsvarienconfigurable.js

  • public_htmljsvarienproduct,js



The question is; should I be editing these files?
Are they core files (that will be replaced if I upgraded Magento)?



If I shouldn't be editing them, what should I do if I want to change the contents of these files?


More From » magento

 Answers
8

Suppose you want to override reload function of product.js



Follow the steps



-> Create a new folder under js folder, in our case under /js/jsoverride/



-> Now create a new js file, in our case we have created /js/jsoverride/product.js with the following code




Product.OptionsPrice.prototype.reload 
= Product.OptionsPrice.prototype.reload.wrap(function(parentMethod){
alert(Override success);
});



-> Add the following code to the proper layout file(catalog.xml/local.xml)




 <reference name=head>
<action method=addJs><script>varien/product.js</script></action>
<action method=addJs><script>jsoverride/product.js</script></action>
......
</reference>



Flush the cache after your are done with your update.



More information see wrap()


[#46174] Tuesday, April 8, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
denism

Total Points: 627
Total Questions: 96
Total Answers: 98

Location: Ivory Coast
Member since Sun, Mar 7, 2021
3 Years ago
;