在 prestashop 添加产品页面中添加产品类型 [英] Adding product type in prestashop add product page
问题描述
我是 prestashop 的新手,我试图在标准产品、虚拟产品、现有产品包之外添加新的产品类型
在informations.tpl文件中添加了这个
<代码><label for="digital_product"><input type="radio" name="type_product" id="digital_product" {if $is_in_pack}disabled="disabled"{/if} value="{Product::PTYPE_DIGITAL}" {if $product_type == Product::PTYPE_DIGITAL}checked="checked"{/if} >{l s='数字产品(服务、预订、可下载产品等)'}
我想将此保存在 ps_product 表中的新列 is_digital 中.iam 在这里击中.请帮忙.是否有任何关于 prestashop 的所有类和功能的完整工作流程的文档?
改变 PrestaShop 的核心工作是一项巨大的工程.对于这种情况,您应该并且必须使用模块.
- 转到
Hook.php
并找到exec()
函数.使用error_log($hook_name)
找出执行特定操作时可用的钩子.例如,当您打开产品编辑页面时,它们可能是FormModifier
挂钩,您可以使用它为新产品类型添加单选框.但这只是添加新类型的化妆品". - 您应该创建一个模块来修改 PrestaShop.首先,尝试查找是否有可用的钩子来修改您需要的内容.如果没有,您将需要覆盖实际的
class/controller
.Overrding 很容易,但通常不推荐.在您的模块文件夹中创建类/控制器文件的副本:modules/yourmodule/override/controller/admin/AdminProductCotnroller.php
并且只保留您覆盖的功能.另外,尝试使 if 有条件:if ($iCanModify) {//修改} else { return parent::method();}
- 追踪产品类型常量、变量或字符串 (Product::TYPE_STANDARD?) 在 PS 文件中出现的任何地方.您将需要修改/添加这些地方的逻辑,以使您成为新人.
Iam new to prestashop ,iam trying to add new product type in addition to Standard product,Virtual product ,Pack of existing products
Added this in informations.tpl file
<
div class="radio">
<label for="digital_product">
<input type="radio" name="type_product" id="digital_product" {if $is_in_pack}disabled="disabled"{/if} value="{Product::PTYPE_DIGITAL}" {if $product_type == Product::PTYPE_DIGITAL}checked="checked"{/if} >
{l s='Digital product (services, booking, downloadable products, etc.)'}</label>
</div>
i want to save this in new column is_digital in ps_product table.iam struck here.Please help. Is there any any documentaion for full working flow of all classes and functions of prestashop?
Changing the core workings of PrestaShop is a HUGE undertaking. You should and must use a module for cases like this.
- Go to
Hook.php
and findexec()
function. Useerror_log($hook_name)
to find out which hook are availble when a specific action is performed. For example, when you open product edit page, they may beFormModifier
hook which you could use to add a radio box for a new product type. But that is just "cosmetics" of adding an new type. - You should create a module for modifying PrestaShop. First, try to find if there is a hook available to modify what you need. If there isn't, you will need to override the actual
class/controller
. Overrding is easy, but generally not recommended. Create copies of class/controller files in your module folder:modules/yourmodule/override/controller/admin/AdminProductCotnroller.php
and only leave functions which you are overrding. Also, try to make if conditional:if ($iCanModify) { // Modify} else { return parent::method(); }
- Track down a product type constant, variable or string (Product::TYPE_STANDARD?) everywhere where it occurs in PS files. You will need to modify/add logic to these places to make you new tyoe work.
这篇关于在 prestashop 添加产品页面中添加产品类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!