0

I'm new to magento and I'm creating an eshop now. I want to add some jquery code to prepopulate some fields I want. For example I want when adding a new Product Category to auto choose "isAnchor" = true and active = true. Also I want when adding a new product to auto choose a certain tax selection and prepopulate some other fields with some values I want as default.

Can some one suggest on where should I put my code in each case to achieve my goal?

Thanks in advance.

4

1 回答 1

5

Step 1>>下载 jquery 并保存到js/jquery目录

步骤 3>>创建一个新的 js 文件js/custom/autoPopulate.js并添加以下内容。

jQuery(document).ready(function(){
   alert('succeed!!'); 
});

第二步>>创建app/design/adminhtml/default/default/layout/local.xml

步骤 3>>将以下代码添加到上面创建的文件中

<layout>
    <adminhtml_catalog_product_edit>
        <reference name="head">
            <action method="addItem">
                <type>js</type>
            <!-- Jquery file path here-->
                <name>jquery/JQUERY_FILE_NAME.js</name>
            </action>
            <action method="addItem">
                <type>js</type>
                <name>custom/autoPopulate.js</name>
            </action>
        </reference>
    </adminhtml_catalog_product_edit>
</layout>

完成上述步骤后,进入目录>>产品>>编辑部分,看到它提示“成功!!”。如果是这样,请在 auoPopulate.js 中编写您的代码。注意,magento 使用 ajax 加载一些数据,最好等到完成 ajax 请求后再执行你的代码,否则可能会抛出错误

于 2013-10-08T04:22:35.640 回答