Question regarding extending the database

Hello everyone,

I have a question regarding the cs-cart database, notably extending certain tables with additional fields.

A basic example of what I am trying to do is add an additional field, for example: “customwidth” in a grid item (table: bm_grids)

I understand that for example, there’s a hook to retrieve additional fields for products: additional_fields_in_search

Is there any “proper” or “right” way for these fields to be added / “registered” in the database eg: in some sort of schema? (Laravel - migrations would be an example of what I’m thinking)

Thank you very much for your time!

The proper way to alter the existing tables via an add-on is to specify the changes in the add-on’s addon.xml file:

    <item for="install">ALTER TABLE ?:products ADD parent_product_id int(11) unsigned NOT NULL DEFAULT '0';</item>
    <item for="uninstall">ALTER TABLE ?:products DROP parent_product_id;</item>

Also please check the examples in the following article:

1 Like