0

カスタマイズするには、ブロック catalog_product_edit_tab_options_type_select を書き直す必要があります。Magento 1.7.0.2 を使用しています。前もって感謝します。

モジュール etc/config.xml に以下のように記述しました。

<config> 
    <modules>
        <My_Module> 
            <version>0.1.0</version>
        </My_Module>
    </modules>
    <global>
        .........
        <blocks>
            <settings>
                <class>My_Module_Block</class>
            </settings>  
        <adminhtml> 
            <rewrite>  
            <catalog_product_edit_tab_options_type_select>
                My_Module_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Type_Select
            </catalog_product_edit_tab_options_type_select>  
            </rewrite>
                 <rewrite>
        <catalog_product_edit_tab_options>
            My_Module_Block_Adminhtml_Catalog_Product_Edit_Tab_Options
        </catalog_product_edit_tab_options>
        </rewrite>  
        </adminhtml>
           .......
        </blocks> 
    </global> 
</config>

オプションブロッククラスを書き換え、

class My_Module_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option
{
    /**
     * Class constructor
     */
    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('my/module/catalog/product/edit/tab/options/option.phtml');
        $this->setCanReadPrice(true);
        $this->setCanEditPrice(true);
    }

    protected function _prepareLayout()
    {
         $this->setChild('dimension_fetchbutton',
            $this->getLayout()->createBlock('adminhtml/widget_button')
                ->setData(array(
                    'label' => Mage::helper('catalog')->__('Get Dimensions'),
                    'class' => 'add_dimensions',
                    'id'    => 'add_dimensions'
                ))
        );

         /*$this->setChild('custom_select_option_type',
                $this->getLayout()->createBlock('settings/catalog_product_edit_tab_options_type_select')
        );*/

        return parent::_prepareLayout();
    }

    public function getDimensionButtonHTML()
    {
       return $this->getChildHtml('dimension_fetchbutton'); 
    }

    /**
     * Retrieve html templates for different types of product custom options
     *
     * @return string
     */
    public function getTemplatesHtml()
    {
        $canEditPrice = $this->getCanEditPrice();
        $canReadPrice = $this->getCanReadPrice();
        $this->getChild('select_option_type')
            *****->setCanReadPrice($canReadPrice)
            ->setCanEditPrice($canEditPrice);******

        $this->getChild('file_option_type')
            ->setCanReadPrice($canReadPrice)
            ->setCanEditPrice($canEditPrice);

        $this->getChild('date_option_type')
            ->setCanReadPrice($canReadPrice)
            ->setCanEditPrice($canEditPrice);

        $this->getChild('text_option_type')
            ->setCanReadPrice($canReadPrice)
            ->setCanEditPrice($canEditPrice);

        $templates = $this->getChildHtml('text_option_type') . "\n" .
            $this->getChildHtml('file_option_type') . "\n" .
            $this->getChildHtml('select_option_type') . "\n" .
            $this->getChildHtml('date_option_type'); 
        return $templates;
    }

}

カスタム選択ブロック クラス、

class My_Module_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Type_Select extends
    Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select
{
    /**
     * Class constructor
     */
    public function __construct()
    {

        parent::__construct();
        $this->setTemplate('my/module/catalog/product/edit/tab/options/type/select.phtml'); 
    }

    protected function _prepareLayout()
    {

        $this->setChild('dimension_fetchbutton',
            $this->getLayout()->createBlock('adminhtml/widget_button')
                ->setData(array(
                    'label' => Mage::helper('catalog')->__('Get Dimensions'),
                    'class' => 'add-dimensions dimension_button_{{option_id}}',
                    'id'    => '{{option_id}}',
                    'style' => 'display:none;float:left;'
                ))
        );


        return parent::_prepareLayout();
    }


    public function getCustomButtonHTML()
    {
        return $this->getChildHtml('dimension_fetchbutton');
    }

} 

エラーがスローされました: 致命的なエラー: /home/vhosts/Magento/Project/app/code/community/My/Module/Block/Adminhtml/Catalog/Product/Edit/Tab の非オブジェクトに対するメンバー関数 setCanReadPrice() の呼び出し/Options/Option.php 81行目

オプション ブロック クラスで**としてマークされたエラー行。この致命的なエラーを克服するための解決策が必要です。

4

1 に答える 1