我在Magneto内部有一个问题,在类别页面中,似乎为产品层级价格添加了两次税收。我正在尝试调试为什么会发生这种情况,所以我看了几个文件:
模板显示正在使用的renderAmountMinimal()函数:
$block->renderAmountMinimal();此函数的块代码:
public function renderAmountMinimal()
{
$id = $this->getPriceId() ? $this->getPriceId() : 'product-minimal-price-' . $this->getSaleableItem()->getId();
$amount = $this->minimalPriceCalculator->getValue($this->getSaleableItem());
print_r($amount);
$amount = $this->minimalPriceCalculator->getAmount($this->getSaleableItem());
if ($amount === null) {
return '';
}
return $this->renderAmount(
$amount,
[
'display_label' => __('As low as'),
'price_id' => $id,
'include_container' => false,
'skip_adjustments' => true
]
);
}在$amount的对象中返回不正确的值。奇怪的是,getValue()似乎显示了正确的数量。然后我想看看$this->minimalPriceCalculator,看看getAmount中发生了什么,但是我不确定如何调试/查看这里发生了什么,因为文件看起来像下面这样:
namespace Magento\Catalog\Pricing\Price;
use Magento\Framework\Pricing\SaleableInterface;
use Magento\Framework\Pricing\Amount\AmountInterface;
interface MinimalPriceCalculatorInterface
{
/**
* Get raw value for "as low as" price
*
* @param SaleableInterface $saleableItem
* @return float|null
*/
public function getValue(SaleableInterface $saleableItem);
/**
* Return structured object with "as low as" value
*
* @param SaleableInterface $saleableItem
* @return AmountInterface|null
*/
public function getAmount(SaleableInterface $saleableItem);
}我已经检查了SaleableInterface,但它看起来与上面的相似,以及之后的每个文件。这个问题似乎很深,只是想知道去哪里看,这样我就能知道为什么会出问题?
发布于 2018-01-18 18:45:04
您可以使用PHPStorm学习本教程(或作为其他集成开发环境的指南)。
magento2的思想是这个接口用于dependency injections,Magento框架会为你初始化它们。因此,通过运行上面的调试器,您将被定向到生成的类。
如果您只想查看这些类,可以在服务器上的根文档var/generation/Magento中搜索该文件。这通常是在命令行界面中运行magento setup:di:compile时生成的。
https://stackoverflow.com/questions/48319066
复制相似问题