Customize and extends

If you want to change something in Ideas Shop functions (backend). You can create a plugins then override (to add more field, save data to another table, ....)

(Same with ideas Cart)

1. extends by add columns (then save in table 'ideas_product')

- For example, you like to add more field in table 'ideas_product'

- Create a plugin, in this plugin, create more (2) fields in table 'ideas_product', for example : 'something1', 'something2'

- in boot() of this plugin, add this code to extends form of product create page

//extend form
Event::listen(
    'backend.form.extendFields',
    function ($widget) {
        // Only for the Product model
        if (!$widget->model instanceof \Ideas\Shop\Models\Products) {
            return;
        }
        $widget->addTabFields([
            'something1' => [
                'tab' => 'other_tab',
                'label' => 'something1',
                'span' => 'left'
            ],
            'something2' => [
                'tab' => 'other_tab',
                'label' => 'something2',
                'span' => 'left'
            ]
        ]);
        // Remove some fields
        //$widget->removeField('qty');
        //$widget->removeField('price_promotion');
    }
);

=> this code to save more field in table 'ideas_product'

2. extends by use event of ideas shop (then save in another tabel)

for example,we can add more field in create page, but name of field has prefix '_'  : '_something1', '_something2'

....
 $widget->addTabFields([
            '_something1' => [
                'tab' => 'other_tab',
                'label' => 'something1',
                'span' => 'left'
            ],
            '_something2' => [
                'tab' => 'other_tab',
                'label' => 'something2',
                'span' => 'left'
            ]
        ]);

Then, in boot() function:

Event::listen('ideas.shop.save_product', function ($productSaved, $post) {
    var_dump($productSaved);
    echo '<br/>';
    var_dump($post);
    die;
});

=> you can use event 'ideas.shop.save_product' to save '_something1' and '_something2' field data to another table