viewthread
Download Now! The Official Magento User Guide (PDF, 217 pages)

Magento

eCommerce Software for Online Growth

Magento Forum

From setting up your store to managing your products, pages and promotions to generating detailed reports, the Magento User Guide empowers the user to utilize the platform for all of its vast capacity.
Available in eBook and Print formats – Download Now!!!
   
Own Product Type
 
Rool
Jr. Member
 
Total Posts:  29
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:  163
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
Jr. Member
 
Total Posts:  29
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
Jr. Member
 
Total Posts:  29
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:  9
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:  3
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:  3
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:  3
Joined:  2009-03-20
 

Ok!! I’ve resolved!!

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

Any clue how you did this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
XoraX
Jr. Member
 
Total Posts:  13
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 ??

 Signature 

Panel Martin : développeur Magento
Seogento : SEO extension for Magento

 
Magento Community Magento Community
Magento Community
Magento Community
 
CollinsHarper
Jr. Member
 
Total Posts:  12
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?

 Signature 

---
Collins Harper
http://www.collinsharper.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
moesian
Jr. Member
 
Total Posts:  14
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
Magento Community
Magento Community
    Back to top
 
© Copyright 2009 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
163533 users|492 users currently online|263667 forum posts