Hi everyone! As you may know, Magento has 5 product types:

  • Simple Product
  • Configurable Product
  • Group Product
  • Virtual Product
  • Downloadable Product.
[yellowbox]Exclusive information: Check out Magento Gift Card extension that gives your customers the widest choice to send and use cards either online or offline with customizable beautiful designs. [/yellowbox]

However, you can create a new product type by yourself. It’s really simple. Before we start, let’s look back at previous post about how to configure server to install Magento.

In this tutorial, I will show you how to do it. Following these steps:

  • Create a new module by yourself or use module Creator.
  • On file config.xml you define product by XML with tags like:
<config>
 <modules>
 <Namespace_Modulename>
 <version>0.9.12</version>
 </Namespace_Modulename>
 </modules>
 <global>
 <catalog>
 <product>
 <type>
 <nameproducttype translate="label" module="modulename">
 <label>My Product Type</label>
 <model>modulename/product_type</model>
 <price_model>modulename/product_price</price_model>
 <is_qty>1</is_qty>
 </nameproducttype>
 </type>
 </product>
 </catalog>
 </global>
</config>

3.  When creating a new product type you need to create two models: type model and price model

  • Product type model with name declared in config.xml file (modulename/product_type) so on this you need to create a product type model .
      
class Yournamespace_Yourmodule_Model_Product_Type extends Mage_Catalog_Model_Product_Type_Abstract
{

    public function prepareForCart(Varien_Object $buyRequest, $product = null)
    {
                // you will process parameters for product before addtocart here
    }

    public function isVirtual($product = null)
    {
           // return True if this product is virtual and false if this product isn't virtual product
    }
}
  • Create model price for your product type : this model will calculate price for this product type.
 
class Yournamespace_Yourmodule_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Price
{
    public function getPrice($product)
    {

        // you make caculate price for this product type here
    }

}

The final step is to log in admin, refresh cache and try to create new product . You will see it work :).

Author

Why Magestore? We believe in building a meaningful & long-term relationship with you.

12 Comments

  1. Thank you for the great post! Hopefully you can answer my question: how is it possible to tell if a cart contains a virtual product AND a simple product? I have so far this:

    if (Mage::getModel(‘checkout/session’)->getQuote()->isVirtual()) {
    //This is a virtual product
    } else {
    //This is not a virtual product
    }

    If a cart has both virtual AND a simple product in there, it returns as “not a virtual product” when I need to know that there IS a virtual product in the cart. Thank you for you time and thank you for your great posts!

  2. Great post, i need to create a new product type for a new project im working on….

  3. I have created new product type but it does not display Price, Special Price, Cost etc. fields under the ‘Prices’ tab at backend product detail page. Please help me if anyone know the solution to get those fields.

  4. Deepak Oberoi Reply

    I wanted to create a custom product type, which has custom checkout process where user selects different options provided. If this is possible in Magento?

    • Hi Deepak,
      Do you mean that you want to create a product type that can be modified in Checkout process? In Magento, when customers come to checkout, they cannot make changes to their ordered products. All options must be done in previous steps.

  5. I want to create the attribute group , which should be display only in specifi product type ..plz help me

  6. Hey ,
    Can you tell us how we can create new product based on group product for instance
    class Yournamespace_Yourmodule_Model_Product_Type extends Mage_Catalog_Model_Product_Type_Group
    so when we create new product it has group product features

    • Hello Sajid,
      As I understand, the class you mentioned should be class Yournamespace_Yourmodule_Model_Product_Type extends Mage_Catalog_Model_Product_Type_Grouped not “_Group” as you wrote). I have not tried this way but I think it is ok because class Yournamespace_Yourmodule_Model_Product_Type extends Mage_Catalog_Model_Product_Type_Grouped extends Mage_Catalog_Model_Product_Type_Abstract, which is the same as class Yournamespace_Yourmodule_Model_Product_Type extends Mage_Catalog_Model_Product_Type_Abstract.
      Try it and hope you success!

  7. I have created new product type but it does not display Price, Special Price, Cost etc. fields under the ‘Prices’ tab at backend product detail page. Please help me if anyone know the solution to get those fields.

    • You go to Catalog> Attributes > Manage Attribute, then search and edit your prices attribute (price, cost, special price…). In the “Apply To” field, you need select your custom product type, save attribute and recheck. Hope it’s helpful!

Write A Comment