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

You made it all the way down here so you must have enjoyed this post! You may also like:

Sticky Sidebar in Magento Danijel Vrgoc
, | 2

Sticky Sidebar in Magento

How to improve usability for Magento 2 add to cart process Filip Svetlicic
Filip Svetlicic, | 2

How to improve usability for Magento 2 add to cart process

Allow backorders on a website scope Luka Rajcevic
Luka Rajcevic, | 4

Allow backorders on a website scope

48 comments

    1. Check the date of this post and then check the date when Magento 2 was first announced.

  1. Custom product type. i want remove shipping address and shipping method. can any one explain me.

  2. I am looking for based on bundle product , i created new data type but in admin panel can not get any associate or bundle product button.
    please any buddy can help me, please give me some solution

  3. Hi Branko Ajzele,

    It’s a great guide… based on this custom product type I have created product with custom attribute, the products are getting listed but how can I show the custom attributes based filter in layered navigation.
    As of now only able to display default product type attribute based filter on layered navigation.

    Pls suggest way to include custom attribute in layered navigation for these custom product type.

    Thanks

  4. I installed the extentsion to Magento ver. 1.9.0.1, but nothing happens.

    Any advice on how to get it working with 1.9.x.x versions?

  5. Is this possible to create a new product type without create extension with direct update of database

  6. I want to know is it possible to IMPORT products via CSV file for custom product type ?

    Or the script you provided is capable for handling default import/export tool functionality of Magento ?

    If NO, then please let me know how can i achieve this ?

  7. Actually I want to do the same as Tihomir Panchev. Does anybody knows solution for this?

  8. Hi! thank you very much for this post! I am wondering, is it possible to delete price section from catalogview for this product, without changing other products? I want to create something like Showroom, where would be only images and description.

  9. when i tried to get the price attribute for the costume product fatal error is displaying

    $_product->getPrice();

    Fatal error: Call to a member function getPrice() on a non-object in /opt/lampp/htdocs/SVE279/app/code/core/Mage/Catalog/Model/Product.php on line 211

    when it checked on the core file i found this

    public function getPriceModel()
    {
    return Mage::getSingleton(‘catalog/product_type’)->priceFactory($this->getTypeId());
    }

    so the problem is with our costume module any solution or fix for this problem

  10. I want to have group item in one (eg:1x itemA, 2x itemB)
    with a fixed discount price.
    But the build in one (group product) can’t.
    Any one can help?

  11. I am looking for based on group or bundle product , i created new data type but in admin panel can not get any associate or bundle product button.

    can any one me out please

  12. Hello,

    I need to build a custom product which should be based on ‘gift card’ product type. Can you pls let me know what all additional codes I have to add to build the same?

    Thanks!

  13. Hi
    Thanks a lot for module sample but Adminhtml edit tabs folder is empty and i need remove some fields on new/edit product form

    ideas ?

  14. Great stuff. But how do you make renderer for the product so it shows in sales object?

  15. I’m looking for a way to create a new product type based on the grouped product too, but with the abilty to group configurable products. Any ideas how to extend the grouped product type?

  16. Hi,
    Thanks for the extension. But I was wondering if there is anyway to make customized product type based on the ” Grouped ” type product? If there is could you tell me how can I set that up? I appreciate any kind of help.

  17. Thanks for the extension.
    I am using it on Magento 1.5 on php 5.3.5 and just had to change the following in sql/mysql4-install-0.1.0.php:

     $applyTo = split(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));

    to..

        $applyTo = explode(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));
  18. its is something to understand in depth for programmer and you make it available …you deserves many many thinks…..

    once more thanks

  19. Hi Branko…

    up to here, everything looks fine and finally i found a customizable product. Unfortunately I am a magento newbie 😛

    My pain is that I want to customize the system fields… What I mean is to remove some of the system attributes e.g. price, stock, qty, add to cart and etc. and to make the product looks like an article: Title, description (short), thumb, images etc. No price, no additional stuff in it.

    Is it possible to do it with your extention? If yes,.. how..

    Thanx
    Grab a beer
    t.

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

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

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

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

  24. Scratch that last comment. Somehow I looked past the same unclosed node like fifty times. All seems well now.

  25. 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?

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

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

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

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

  30. @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 😀

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

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

  33. 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.. 😀

  34. 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 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.