Allows to define new columns in the product model.
You can download a module template extending the product model in
Module Templates
documentation section.
The event handler should accept a single parameter - the product object. To add new columns to the product model,
call the
define_column() method of the product object. Before you add new columns to the model,
you should add them to the database (the
shop_products table).
public function subscribeEvents()
{
Backend::$events->addEvent('shop:onExtendProductModel', $this, 'extend_product_model');
Backend::$events->addEvent('shop:onExtendProductForm', $this, 'extend_product_form');
}
public function extend_product_model($product)
{
$product->define_column('x_extra_description', 'Extra description');
}
public function extend_product_form($product, $context)
{
$product->add_form_field('x_extra_description')->tab('Product');
}