Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.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
Magento,如何在查看页面中更改产品价格?_Magento - Fatal编程技术网

Magento,如何在查看页面中更改产品价格?

Magento,如何在查看页面中更改产品价格?,magento,Magento,在Magento产品视图页面中 我需要使用产品选项调用第三方API以获取产品价格, 我需要动态地改变产品价格 如何更新查看页面中的产品价格,以便将正确的价格传递给购物车 我尝试在options.phtml中添加此输入标记 <input type='text' name='price' value='999' /> 我单击“添加到购物车”按钮,但价格在购物车页面中没有更改 请告知我,您将无法以这种方式设置自定义价格,因为当magento将产品添加到购物车时,它不会从表单post数

在Magento产品视图页面中

我需要使用产品选项调用第三方API以获取产品价格, 我需要动态地改变产品价格

如何更新查看页面中的产品价格,以便将正确的价格传递给购物车

我尝试在options.phtml中添加此输入标记

<input type='text' name='price' value='999' />

我单击“添加到购物车”按钮,但价格在购物车页面中没有更改


请告知我,

您将无法以这种方式设置自定义价格,因为当magento将产品添加到购物车时,它不会从表单post数据中获取价格

在magento中,可以选择在运行时设置产品的自定义价格。因此,您必须在结账时调用观察者\购物车\产品\在事件发生后添加\在该观察中,从表单post数据中获取自定义价格,并按以下方式设置产品自定义价格:

  $request=$observer->getRequestParam();
  $price=$request->getPrice();
  $qty=1;
  $item = $observer->getQuoteItem();
  $item->setCustomPrice($price*$qty);
  $item->setOriginalCustomPrice($price);
  // Enable super mode on the product.
  $item->getProduct()->setIsSuperMode(true);

你想更新该产品的价格还是什么。。?请简要解释一下。。