製品編集ページfunction loadImage
からオーバーライドするとします。js/mage/adminhtml/product.js
カスタムjsを作成します
js/myfolder/myproduct.js
::
Product.Gallery.addMethods({
loadImage : function(file) {
alert('hi there');
var image = this.getImageByFile(file);
this.getFileElement(file, 'cell-image img').src = image.url;
this.getFileElement(file, 'cell-image img').show();
this.getFileElement(file, 'cell-image .place-holder').hide();
}
});
参照: http: //prototypejs.org/learn/class-inheritance.html
次に、レイアウトxmlにカスタムjsを追加します。
<adminhtml_catalog_product_edit>
<reference name="head">
<action method="addJs"><script>myfolder/myproduct.js</script></action>
</reference>
</adminhtml_catalog_product_edit>
このメソッドを使用function loadImage
すると、を含めた場合にのみオーバーライドされますjs/myfolder/myproduct.js
。
PS:js/myfolder/myproduct.js
後に含まれていることを確認してください(タグに含まれてjs/mage/adminhtml/product.js
いるため、デフォルトではそのようになっています)js/mage/adminhtml/product.js
<default>