Create a new product type
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 !
I’m on holidays till 22/07, so this page can stay unupdated till this date.
Good to know |
| Option | Value |
|---|---|
| Magento version | 1.4.1.0 Stable |
| Namespace for tutorial | Namespace |
| Module name for tutorial | Rate |
Steps |
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.
- <?xml version="1.0"?>
- <config>
- <modules>
- <Namespace_Rate>
- <version>0.1.0</version>
- </Namespace_Rate>
- </modules>
- <global>
- <helpers>
- <rate>
- <class>Namespace_Rate_Helper</class>
- </rate>
- </helpers>
- <catalog>
- <product>
- <type>
- <rate translate="label" module="rate">
- <label>Rate Product</label>
- <model>rate/product_type_rate</model>
- <composite>0</composite>
- <index_priority>12</index_priority>
- </rate>
- </type>
- </product>
- </catalog>
- </global>
- <adminhtml>
- <translate>
- <modules>
- <Namespace_Rate>
- <files>
- <default>Namespace_Rate.csv</default>
- </files>
- </Namespace_Rate>
- </modules>
- </translate>
- <layout>
- <updates>
- <rate>
- <file>rate.xml</file>
- </rate>
- </updates>
- </layout>
- </adminhtml>
- </config>
2. 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).
- <models>
- <rate>
- <class>Namespace_Rate_Model</class>
- </rate>
- </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
You can just copy the simple product type classes and add your own methods


