Reputation: 77
I wanted to build Custom Input Fields in Magentos Product/Custom Option Area. I started to write a new Module. In "etc/modules" i created "Pi_Customize.xml"
<?xml version="1.0"?>
<config>
<modules>
<Pi_Customize>
<active>true</active>
<codePool>local</codePool>
</Pi_Customize>
</modules>
</config>
in "app/code/local/etc" I created the "config.xml"
<?xml version="1.0"?>
<config>
<modules>
<Pi_Customize>
<version>0.1</version>
</Pi_Customize>
</modules>
<global>
<catalog>
<product>
<options>
<custom>
<groups>
<custom translate="label" module="customize">
<label>Custom Stuff</label>
<render>customize/adminhtml_catalog_product_edit_tab_options_type_custom</render>
<types>
<custom_type translate="label" module="customize">
<label>Custom Text</label>
</custom_type>
</types>
</custom>
</groups>
</custom>
</options>
</product>
</catalog>
</global>
</config>
when i reload in backend/product/custom options i see the new added field, but i get an error:
exception 'Mage_Core_Exception' with message 'Invalid block type: Mage_Customize_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Type_custom' in /home/michi/www/magento/app/Mage.php:595
I am trying around about 4 hours, and can't get it tor work. Why is Magento trying to load "mage" instead of "pi/customize". How should the folder Structure then look like?
A: "Adminhtml/block/catalog....."
B: "Block/catalog..."
C: another?
Upvotes: 0
Views: 4290
Reputation: 166076
Your post lacks some context, and it's unclear what you think the above should do, so that makes it hard to completely address your question.
That said, your configuration indicated you want to use the following block class as a render
<render>customize/adminhtml_catalog_product_edit_tab_options_type_custom</render>
This means Magento will attempt to instantiate the a customize/adminhtml_catalog_product_edit_tab_options_type_custom
block class. There is not a customize
block namespace in a stock Magento system, and you haven't added one via your configuration. That means customize/adminhtml_catalog_product_edit_tab_options_type_custom
corresponds to the PHP class
Mage_Customize_Helper_Adminhtml_Catalog_Product_Edit_Tab_Options_Type_Custom
This class doesn't exist in Magento, and you get the error you get.
Although your error is curious as well. The lower case custom (Options_Type_custom
) makes is seem like there's other things going on you haven't mentioned in your question.
Upvotes: 2
Reputation: 77
Thanks for your help, i changed my config.xml, like this:
<config>
<modules>
<Pi_Customize>
<version>0.1</version>
</Pi_Customize>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<catalog_product_edit_tab_options_option>
Pi_Customize_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option
</catalog_product_edit_tab_options_option>
</rewrite>
</adminhtml>
<customize>
<class>Pi_Customize_Block</class>
</customize>
</blocks>
<catalog>
<product>
<options>
<custom>
<groups>
<customize translate="label" module="customize">
<label>Customized Input</label>
<render>customize/adminhtml_catalog_product_edit_tab_options_type_customized</render>
<types>
<customize_type translate="label" module="customize">
<label>custom</label>
</customize_type>
<!-- the second one
<customizedue_type translate="label" module="customize">
<label>due</label>
</customizedue_type>
-->
</types>
</customize>
</groups>
</custom>
</options>
</product>
</catalog>
</global>
</config>
Now i get the error "Invalid block type: Pi_Customize_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option". But my file is stored at: "app/code/local/Pi/Customize/Block/Adminhtml/Catalog/Product/Edit/Tab/Options/Option.php". I don't know what I'm doing wrong?
Edit: I found the error, i typed
<adminhtml>
<rewrite>
<class_to_override>
my_class
</class_to_override>
</rewrite>
</adminhtml>
but it has to be:
<adminhtml>
<rewrite>
<class_to_override>my_class</class_to_override>
</rewrite>
</adminhtml>
Upvotes: 2