Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在prestashop中为一个产品进行自定义计算_Php_Prestashop - Fatal编程技术网

Php 在prestashop中为一个产品进行自定义计算

Php 在prestashop中为一个产品进行自定义计算,php,prestashop,Php,Prestashop,我想知道在普雷斯塔商店的哪个文件中计算产品价格?我为其中一个产品添加了两个属性,但我想做如下操作 if(product_id = 44) { attribute1 + (attribute1 x attribute2) = the price }else { the usual calculation... } 现在,价格根据attribute1+attribute2中选择的内容而变化,我找不到任何关于presta文档的帮助,我真的需要它。我认为您正在使用Presta

我想知道在普雷斯塔商店的哪个文件中计算产品价格?我为其中一个产品添加了两个属性,但我想做如下操作

 if(product_id = 44) {
    attribute1 + (attribute1 x attribute2) = the price
  }else {
    the usual calculation...
  }

现在,价格根据attribute1+attribute2中选择的内容而变化,我找不到任何关于presta文档的帮助,我真的需要它。

我认为您正在使用Prestashop 1.5.x

在Classes/Product.php中,有一个函数的代码如下:

public static function getProductAttributePrice($id_product_attribute)
{
    return Combination::getPrice($id_product_attribute);
}
或者你可以直接在办公室工作

Combination::getPrice($id_product_attribute);
您需要做什么来重写组合类或产品类,并重载该函数。让我们采用组合类,因为getProductAttributePrice将来将被弃用

因此,重写组合类并重载getPrice函数。您需要做的是将产品id也传递给它,以便进行计算

现在您可能知道了这方面的属性id,所以如果产品id为144,那么这两个属性都是价格,并相应地处理它们并返回它

注意:这只是给你一个想法。它可能有效,也可能无效。

我希望这会有帮助。如果你仍然没有得到你的结果,那么让我知道,我会回答

谢谢