我正在开发 Shopware 6 插件。
<?php declare(strict_types=1);
namespace ReCachePlugin\Listener;
use Shopware\Core\Framework\DataAbstractionLayer\Pricing\Price;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
class ProductLoadedListener{
public function onProductLoaded(EntityLoadedEvent $entityLoadedEvent){
print_r($entityLoadedEvent->getIds());
print_r($price->getNet());
}
}
下面是我的 services.xml 文件
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="ReCachePlugin\Listener\ProductLoadedListener" >
<tag name="kernel.event_listener" event="product.loaded" />
</service>
</services>
</container>
这可行print_r($entityLoadedEvent->getIds());
,但这print_r($price->getNet());
不起作用我尝试在类$price = new Price
内部和外部实例化类,ProductLoadedListener
但我得到了错误。
那我该如何让它print_r($price->getNet());
工作呢?