Create a new product type

Last modified by Jona on Mon, August 16, 2010 08:41
Source|Old Revisions  

This is an old revision of the document!

Please Note

Here you’ll find all the necessary about creating a new product type. This page is currently under construction. Keep watching about evolutions soon !

Good to know

Option Value
Magento version Stable
Namespace for tutorial Namespace
Module name for tutorial Rate


1. Create new module

First, we must create our new module. We will made the module as simplest as possible.

Actually, we just need the config file and the helper (every module needs a helper). We also create a translation file and a layout update file and declare it in the config file).

And of course, we need to declare our new module by adding a new file in /app/etc/modules/ named Namespace_Rate.xml

Here an exemple of our actual config file. Please note the layout and translation files are added to adminhtml tags and not on the frontend one.

  1. <?xml version="1.0"?>
  2. <config>
  3.     <modules>
  4.         <Namespace_Rate>
  5.             <version>0.1.0</version>
  6.         </Namespace_Rate>
  7.     </modules>
  8.     <global>
  9.         <helpers>
  10.             <rate>
  11.                 <class>Namespace_Rate_Helper</class>
  12.             </rate>
  13.         </helpers>
  14.     </global>
  15.     <adminhtml>
  16.         <translate>
  17.             <modules>
  18.                 <Namespace_Rate>
  19.                     <files>
  20.                         <default>Namespace_Rate.csv</default>
  21.                     </files>
  22.                 </Namespace_Rate>
  23.             </modules>
  24.         </translate>
  25.         <layout>
  26.             <updates>
  27.                 <rate>
  28.                     <file>rate.xml</file>
  29.                 </rate>
  30.             </updates>
  31.         </layout>
  32.     </adminhtml>
  33. </config>

Creating models

In order to create a new product type, we need to create some additionnal models inside our module.

So we need to declare it in our config file (inside <global> tags).

  1. <models>
  2.     <rate>
  3.         <class>Namespace_Rate_Model</class>
  4.     </rate>
  5. </models>

We need to create 3 different classes:

/app/code/local/Namespace/Rate/Model/Product/Type.php /app/code/local/Namespace/Rate/Model/Product/Price.php /app/code/local/Namespace/Rate/Model/Product/Type/Rate.php