How to create a new product type in Magento
18 Comments 21st JAN 2010 | Posted by Branko Ajzele in Magento

Magento comes packed with several product types: simple, grouped, configurable, virtual, bundle, downloadable. Sometimes clients request can reach beyond any of these built in product types functionality. In such cases, usual way of handling things is throwing some new attributes and hooking into some events from which you can handle and “re-route” certain logic.
In some cases, the required product logic can extend to such level that you are better of with building a new product type in Magento. Why, you might ask? Becase of the more finer control you can achieve on product trough your own models than to poke around on the existing stuff.
Attached to this article is a fully working extension I wrote that creates a new product type in your Magento store. This new product type uses code name “customproduct”. Its based on the Mage_Catalog_Model_Product_Type_Abstract class, the one on which the “simple” product is build upon. Unlike “simple” product type, this “customproduct” does not have any, whatsoever, additional logic built in. This, I leave to you.
Also, extension comes with several “hooks” to certain Magento controllers actions. If you open the app/code/local/Ajzele/CustomProduct/Model/Observer.php you will see implemented several “blank” methods as hooks. Going to config.xml file of this extension will show you what these methods “observe”.
Here are few screenshots of how this looks like on frontend and on backend.
And here is the module (extension), Ajzele_CustomProduct.
Note, DO NOT INSTALL the extension on LIVE SITE. Use it merely for development testing and getting to know Magento product types. Extension is tested on my PC, latest Magento 1.3.2.4 version and it seems to work fine, both in admin and frontend. It is by no means intendant to be used on live site. Use it at your own responsibility.
Hope you find it useful
Cheers.
To post code in comments, place your code inside [code] and [/code] tags.

























January 21st, 2010 at 13:49
Does it work in Magento 1.4? I’ve done some extensions for 1.3.2.4 (like creating custom checkout fields) but they just stop working in 1.4
January 22nd, 2010 at 11:57
Nice post.. will look into this…but…. I can’t think of a situation..when..I need to create a product type…Can you provide me any..situation..
January 23rd, 2010 at 15:13
Hi there,
I dint understand the need of this. Let me clear my point.
I think, we can just use Simple Product Type always.
Kindly give us an example of a situation, when you may need this.
Im sure, you would have come across any client’s requirements and thats why, you would have done this and just wrote this .
So, let us know that situation.
Thanks.
January 23rd, 2010 at 19:11
@All
There are tons of scenarios one might need custom product type, such as more finer control over “live products” that are pulled via some feed from some third party service or etc….
For all those who do not “understand the need for custom product” type, answer might be brutal but simple, please ignore this the article and attached extension. In short, consider yourself lucky if you won’t need to create a new product type ever.
Happy coding people.
January 24th, 2010 at 6:45
@Branko
This post is impossible.. to ignore..coz.. I can learn from this.. about Magento’s ins and outs
.
Also..will post a thank you… after…if I ever need a custom product type
February 1st, 2010 at 20:59
We’re trying to develop a product type of “schematic”, which is similar to a grouped product, but needs reference numbers and quantities for each part that goes to the product listed. Using this, it should be much easier. Thanks.
February 14th, 2010 at 21:06
Thanks for this. This would really be great in testing new products. I’m also following your note; not using it on live site.
March 18th, 2010 at 1:05
We customize the hell out of our products! … i am not a coder, but i like to learn about what is happening in the development world so i can keep my coders “honest” and get ideas for us.
We had a situation where we built a theatre booking system and the coders had to customize the a simple product and instructed us to “duplicate” this simple product for additional concerts. So this can help us greatly (I think!!)
But, a question just so i can understand and talk with some “authority” with my coders, how is this product different from a simple product? i can’t read php to save my life and the tabs seem similar to what one would usually see in a simple product.
March 19th, 2010 at 8:39
@Nasser
This specific product in the example is not that different from Simple product type. However, it enables you now to do any custom logic in the model that will make it a whole lot different then any product type in Magento
-For example, if you use “duplicate” function a lot I would guess you are using it in order to “presetting” some values for product so you do not have to fill them in each time manually. Why not do so with the code in your custom product type?! Just a thought.
Cheers.
March 19th, 2010 at 18:23
ok. now i understand. The fact this code creates a new product type means we can have the additional logic embedded in this product type.
I will share with you the example once we do it
Many thanks for the explanation.
March 30th, 2010 at 19:02
I’m using this code with Magento 1.4.0.1 and I keep getting this error:
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 46: parser error : Opening and ending tag mismatch: blocks line 26 and global in /home/drjsafety/www/www/lib/Varien/Simplexml/Config.php on line 510″
I went through config.xml adding nodes one by one until I could get the error to repeat and seems to be caused by the catalog node.
Do you have any more insight into what’s causing this?
March 30th, 2010 at 19:24
Scratch that last comment. Somehow I looked past the same unclosed node like fifty times. All seems well now.
April 1st, 2010 at 12:50
The zip file seems to be invalid. Could you fix it please?
April 14th, 2010 at 21:01
Couldn’t you just create a new attribute set to accomplish? What did you use this for, specifically?
April 15th, 2010 at 1:15
This is how our team plans to use it (not sure if we can or not, though) … for example we have a product that simulates a theater booking system. In addition to the attributes, we have specific code within the product. Every time we need to create a new theater event, we have to duplicate a product. Now, if we can create a new product type and embed in it our code, then we can simply create a theater event as opposed to duplicating the original product.
April 15th, 2010 at 5:11
This is just what i was looking for. Wanted to copy & make some changes to the bundled product type. This will come in handy at learning Magento. Just started looking into it yesterday, but i soon learned it has serious drawbacks when it comes to price calculation based on chosen attributes.
May 20th, 2010 at 15:38
ok. now i understand. The fact this code creates a new product type means we can have the additional logic embedded in this product type.
I will share with you the example once we do it
Many thanks for the explanation.
June 21st, 2010 at 9:48
Hi Coders,
It’s a very interesting article !
Do you know how to add some tabs with specific informations linked to our new product type?
Just like downloadable products… I’ve tried to look in the code of downloadble module but i’m lost…
I want to create a product type ‘Rateable’, these products must have a start and end date for the rates, an estimated price, …
I cant create a new attribute set ‘Rateable’ because the rateable products can have another attribute set with other attributes…
I wish you beleive me with my bad english…
Thanks ! Jona