Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Own Product Type
 
Rool
Member
 
Total Posts:  36
Joined:  2008-09-03
 

Hi,

i would like to create a new product type for some special reasons.

in the
code/core/Mage/Catalog/etc/config.xml
the different types are configured under:
<global>
<catalog>
<product>
<type>

now i created my own module with my own config:

<global>
<catalog>
<product>
<type>
<newone translate="label" module="my_mod">
<label>New Product Type</label>
<model>catalog/product_type_mytype</model>
<index_priority>0</index_priority>
</newone>
</type>
</product>
</catalog>
</global>

the config is read correctly and the type is shown in the admin, when creating a new product. i can select the type, but when clicking “Next”, i get the error:

Warning: include(Mage/Catalog/Model/Product/Type/Mytype.php) [function.include]: failed to open stream: No such file or directory

how can i tell magento to use my own module-directory not the “Mage”?
i want put the Mytype.php in my module-dir…

thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
retif
Sr. Member
 
Total Posts:  171
Joined:  2008-08-16
Odessa, Ukraine
 

<model>catalog/product_type_mytype</model>

here you pointing magento to “Mage” folder, becouse “catalog” module is there(in xml configs).
use your own module instead of “catalog”

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rool
Member
 
Total Posts:  36
Joined:  2008-09-03
 

but i want to use catalog, because it belongs to this module. usually i can override the modules, but how tell him to look in “mycompany/catalog” ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rool
Member
 
Total Posts:  36
Joined:  2008-09-03
 

no way? normal modules i override also in this way…

 
Magento Community Magento Community
Magento Community
Magento Community
 
egabbud
Jr. Member
 
Total Posts:  10
Joined:  2008-07-16
 

You may have figured this out since then, but what you’re missing is a rewrite rule to say where your implementation class is:

in your_module/etc/config.xml:

<global>        
    <
models>
         <
catalog>
               <
rewrite>
                    <
product_type_mytype>MyCompany_Catalog_Model_Product_Type_MyType</product_type_mytype>
               </
rewrite>
         </
catalog>
   </
models>
</global>

And then create in your module local code pool the following class:

class MyCompany_Catalog_Model_Product_Type_MyType extends Mage_Catalog_Model_Product_Type_Abstract
 
Magento Community Magento Community
Magento Community
Magento Community
 
Davide Fiorello
Jr. Member
 
Total Posts:  4
Joined:  2009-03-20
 

I try to follow your suggestion to make a costom product type but the rewrite rule don’t’ work.

<?xml version="1.0"?>
<config>
    <
modules>
        <
BH_Rentable>
            <
version>0.1.0</version>
        </
BH_Rentable>
    </
modules>
    <global>
        <
catalog>
            <
product>
                <
type>
                    <
rentable translate="label" module="rentable">
                        <
label>Rentable Product</label>
                        <
model>rentable/product_type</model>
                        <
composite>0</composite>
                    </
rentable>
                </
type>
            </
product>
        </
catalog>
        <
models>
            <
BH_rentable>
                <
rewrite>
                    <
product_type_rentable>BH_Rentable_Model_Product_Type</product_type_rentable>
                </
rewrite>
            </
BH_rentable>
        </
models>
    </global>
</
config>

This is the error

Warning: include(Mage\Rentable\Model\Product\Type.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\magento\app\code\core\Mage\Core\functions.php on line 70
Trace:
#0 C:\xampp\htdocs\magento\app\code\core\Mage\Core\functions.php(70): mageCoreErrorHandler(2, ‘include(Mage\Re...’, ‘C:\xampp\htdocs...’, 70, Array)
#1 C:\xampp\htdocs\magento\app\code\core\Mage\Core\functions.php(70): __autoload()
#2 [internal function]: __autoload(’Mage_Rentable_M...’)
#3 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Config.php(970): class_exists(’Mage_Rentable_M...’)
#4 C:\xampp\htdocs\magento\app\Mage.php(317): Mage_Core_Model_Config->getModelInstance(’rentable/produc...’, Array)
#5 C:\xampp\htdocs\magento\app\Mage.php(331): Mage::getModel(’rentable/produc...’, Array)

I put the module in the community folder.

Wath’is wrong??

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Davide Fiorello
Jr. Member
 
Total Posts:  4
Joined:  2009-03-20
 

This to don’t work

<models>
            <
catalog>
                <
rewrite>
                    <
product_type_rentable>BH_Rentable_Model_Product_Type</product_type_rentable>
                </
rewrite>
            </
catalog>
        </
models>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Davide Fiorello
Jr. Member
 
Total Posts:  4
Joined:  2009-03-20
 

Ok!! I’ve resolved!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
twistedindustries
Member
 
Total Posts:  64
Joined:  2008-06-09
 

Any clue how you did this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
XoraX
Member
 
Avatar
Total Posts:  37
Joined:  2007-09-03
Lyon, France
 

<model>rentable/product_type</model> => Mage\Rentable\Model\Product\Type.php

Add another product type is very usefull.

@Davide Fiorello :
You say “I put the module in the community folder”, where is it ??

 
Magento Community Magento Community
Magento Community
Magento Community
 
CollinsHarper
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2008-08-14
Vancouver, BC
 

We’ve been working on a module to add an additional product type as well and we’re running into the same issue:

Warning: include(Mage\Rentable\Model\Product\Type.php)

You need to have the XML setup like:

<global>
    <
catalog>
            <
product>
                <
type>
                      <
yourtype translate="label" module="yourcompany_yourmodule">
                          <
label>your product type label</label>
                          <
model>yourcompany_yourmodule/path_to_your_model</model
                          <
composite>0</composite>
                 </
type>
            </
product>
       </
catalog>
...

Entering the above gets you a menu selection in the drop down menu when you add a product; which obviously is key, but when you try to use that menu item, it will try to load:

Mage/yourcompany/yourmodule/model/path/to/your/model.php

All this is fine except the Mage/ part.

So how do configure the XML so that you get both a menu item AND a correct path to your file all while keeping your files outside the mage name space?

 
Magento Community Magento Community
Magento Community
Magento Community
 
moesian
Jr. Member
 
Total Posts:  18
Joined:  2009-10-05
 

Hi,

I’ve followed all your great help for creating a new product type, but I’m having quite a serious issue.

I’m basically trying to create a new product type based on grouped products so I’m using the grouped product model and overiding it. I can get the new product type to display in the backend, however when it comes to saving the product I get the following error

Data retreiver for ‘multi’ is not defined

Anyone else experienced this, I’m guessing I’ll have to create/override some additional files to get this working but I have no idea where to begin on this.

Any help much appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
matt hardy
Jr. Member
 
Total Posts:  2
Joined:  2009-12-13
 

I am having a similar issue.
I can’t seem to locate anything in the documentation for product types that will help.
Product type shows up in selection but upon save it goes to a new product and is not saving any product of the new type.
Anyone have any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Frederik Krautwald
Member
 
Avatar
Total Posts:  58
Joined:  2007-09-25
Reykjavík, Iceland
 
CollinsHarper - 21 October 2009 07:33 AM

We’ve been working on a module to add an additional product type as well and we’re running into the same issue:

Warning: include(Mage\Rentable\Model\Product\Type.php)

You need to have the XML setup like:

<global>
    <
catalog>
            <
product>
                <
type>
                      <
yourtype translate="label" module="yourcompany_yourmodule">
                          <
label>your product type label</label>
                          <
model>yourcompany_yourmodule/path_to_your_model</model
                          <
composite>0</composite>
                 </
type>
            </
product>
       </
catalog>
...


Entering the above gets you a menu selection in the drop down menu when you add a product; which obviously is key, but when you try to use that menu item, it will try to load:

Mage/yourcompany/yourmodule/model/path/to/your/model.php

All this is fine except the Mage/ part.

So how do configure the XML so that you get both a menu item AND a correct path to your file all while keeping your files outside the mage name space?

Any follow up on this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Frederik Krautwald
Member
 
Avatar
Total Posts:  58
Joined:  2007-09-25
Reykjavík, Iceland
 

I got this code for the config.xml file from Davide Fiorello. It solves the problem that Magento is looking in the Mage folder instead of your custom module. Thank you Davide!!!

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyNameSpace_MyProduct>
            <
version>0.1.1</version>
        </
MyNameSpace_MyProduct>
    </
modules>
    <global>
        <
models>
            <
MyNameSpace_MyProduct>
                <
rewrite>
                    <
product_type>MyNameSpace_MyProduct_Model_Product_Type</product_type>
                </
rewrite>
            </
MyNameSpace_MyProduct>
            <
MyNameSpace_MyProduct>
                <class>
MyNameSpace_MyProduct_Model</class>
            </
MyNameSpace_MyProduct>
        </
models>
        <
blocks>
            <
MyNameSpace_MyProduct>
                <class>
MyNameSpace_MyProduct_Block</class>
            </
MyNameSpace_MyProduct>
        </
blocks>
        <
catalog>
            <
product>
                <
type>
                    <
myProduct translate="label" module="MyNameSpace_MyProduct">
                        <
label>MyProduct Product</label>
                        <
model>MyNameSpace_MyProduct/product_type</model>
                    </
myProduct>
                </
type>
            </
product>
        </
catalog>
    </global>
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Frederik Krautwald
Member
 
Avatar
Total Posts:  58
Joined:  2007-09-25
Reykjavík, Iceland
 
moesian - 08 November 2009 08:38 AM

Hi,

I’ve followed all your great help for creating a new product type, but I’m having quite a serious issue.

I’m basically trying to create a new product type based on grouped products so I’m using the grouped product model and overiding it. I can get the new product type to display in the backend, however when it comes to saving the product I get the following error

Data retreiver for ‘multi’ is not defined

Anyone else experienced this, I’m guessing I’ll have to create/override some additional files to get this working but I have no idea where to begin on this.

Any help much appreciated.

You need to add index_data_retreiver tag to your config.xml

<global>
        <
catalog>
            <
product>
                <
type>
                    <
yourproducttype translate="label" module="YourNamespace_Modulename">
                        <
label>Modulename Product</label>
                        <
model>YourNamespace_Modulename/product_type_name</model>
                        <
composite>0</composite>
                        <
index_data_retreiver>YourNamespace_Modulename/catalogIndex_data_yourproducttype</index_data_retreiver>
                    </
yourproducttype>
                </
type>
            </
product>
        </
catalog>
    </global>

The coder from Magento mispelled retreiver, but that is just how it is. So make sure you also spell it wrong!!!

Then you need to add the index data retreiver file to your module. Create YourNamespace/Modulename/Model/CatalogIndex/Data/YourProductType.php and put the following code in it:

<?php
class YourNamespace_Modulename_Model_CatalogIndex_Data_YourProductType extends Mage_CatalogIndex_Model_Data_Abstract
{
    
/**
     * Retreive product type code
     *
     * @return string
     */
    
public function getTypeCode()
    
{
        
return YourNamespace_Modulename_Model_Product_Type::TYPE_YOURPRODUCTTYPE;
    
}
}

Also add the const TYPE_YOURPRODUCTTYPE in your YourNamespace_Modulename_Model_Product_Type class file.

TIP: Take a look at the Bundle/CatalogIndex/Data/Bundle.php

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2