PrestaShop:节省制造商

I asked this same question on the official forums but received no response. Not sure if anyone here is experienced with PrestaShop but here is my issue.

I need to add an extra field in the manufacturer edit/add tab, I was able to do this by overriding renderForm in AdminManufacturersController.php like this:

public function renderForm()
{
    global $shopOptions;
    $this->fields_form_override = array(
         array(
             'type' => 'checkbox',
             'label' => 'Shop',
             'name' => 'shop_select',
             'desc' => 'Choose The Shops This Manufacturer Applies To',
             'values' => array(
                 'query' => $shopOptions, >> comes from array filled by db query in __construct
                 'id' => 'id',
                 'name' => 'name'
             ),
         ),
     );
    return parent::renderForm();

}

This works and I am now trying to find the update and create functions for a manufacturer. When editing the product classes, you can easily spot set functions like setQuantity in StockAvailable.php.

I have ssh access to the server so I was able to dig deeper with grep, to no avail. It seems like it uses some sort of function to auto insert into the database whilst some classes use a plain old execute with a normal query.

Any ideas on where this could be found?

On Prestashop 1.6.x you do not need to amend any function for it to have CRUD functionalities. You just need to add it in :

  • RenderForm (like you already did)
  • Add the variable in the manufacturer class (Manufacturer.php) like public $shop_select;
  • Add it in the public static $definition array in the manufacturer class
  • Add the column in manufacturer or manufacturer_lang table depending on whether your field is a lang field.

Cheers :)