download2014711 2018-07-25 08:45
浏览 30

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?

  • 写回答

1条回答 默认 最新

  • dqpfl2508589 2018-07-26 09:29
    关注

    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 :)

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么