Wednesday 26 October 2016

How to add js in magento


There is a two way to add js in magento module


/projectname/skin/frontend/base/default/js/myproduct.js

<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
   <catalog_product_view>
       <reference name="head">
           <action method="addItem">
               <type>skin_js</type><name>js/myproduct.js</name>
           </action>
       </reference>
   </catalog_product_view>
</layout>

2. /projectname/js/myproduct.js

<layout version="0.1.0">
   <catalog_product_view translate="label">
       <reference name="head">
           <action method="addJs"><script>myproduct.js</script></action>
        </reference>        
   </catalog_product_view>
</layout>

I hope it will work for you. Good Luck

If you have any query then feel free to contact me at Jainish Senjaliya

No comments:

Post a Comment