How to create a new product type in Magento

7 Comments 21st JAN 2010 | Posted by Branko Ajzele in Magento

How to create a new product type 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.

If you like what you read, please share it.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Yahoo! Bookmarks
  • Reddit
  • Technorati
  • Twitter
  • StumbleUpon
  • LinkedIn
  • Netvibes
  • FriendFeed
  • NewsVine
  • Sphinn
  • Tumblr

There are 7 comments (Add Yours +)

  • 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 :(

  • 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.. :D

  • 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.

  • @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.

  • @Branko

    This post is impossible.. to ignore..coz.. I can learn from this.. about Magento’s ins and outs :D .

    Also..will post a thank you… after…if I ever need a custom product type :D

  • 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.

  • Thanks for this. This would really be great in testing new products. I’m also following your note; not using it on live site.

Leave a Comment

Magento Design and Development | Magento SEO | iPhone Application Development Web Application Development with ZEND | WordPress Ecommerce | WordPress development
Sitemap

Inchoo - webappsolutions | 2009