LemonStand Documentation

shop:onExtendOptionModel event

The shop:onExtendOptionModel event allows to add new columns to the product option model. Before you add columns to the model, your module should add corresponding columns to the database (the shop_custom_attributes table). You can learn about updating the database structure from the Creating and updating database tables article.

The event handler should accept a single parameter - the option object (Shop_CustomAttribute class). Example:

public function subscribeEvents()
{
	Backend::$events->addEvent('shop:onExtendOptionModel', $this, 'extend_option_model');
	Backend::$events->addEvent('shop:onExtendOptionForm', $this, 'extend_option_form');
}

public function extend_option_model($option)
{
	$option->define_column('x_color', 'Color');
}
		 
public function extend_option_form($option, $context)
{
	$option->add_form_field('x_color');
}

Next: shop:onExtendOptionForm event
Previous: cms:onAfterHandleAjax event
Return to Handling LemonStand events