I have a plugin running afterGetPrice(). This is working correctly in the frontend but does not work in the admin area. I have placed my di.xml in the following locations:
<moduleDir>/etc/frontend/di.xml
<moduleDir>/etc/adminhtml/di.xml
The content of these di.xml files is:
adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Model\Product">
<plugin name="sulman-product-model-admin" type="Sulman\Test\Plugin\ProductPlugin" sortOrder="1" />
</type>
</config>
frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Model\Product">
<plugin name="sulman-product-model-frontend" type="Sulman\Test\Plugin\ProductPlugin" sortOrder="1" />
</type>
</config>
My Plugin code is:
<?php
namespace Sulman\Test\Plugin;
class ProductPlugin
{
protected $objectManager;
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
}
public function afterGetPrice(\Magento\Catalog\Model\Product $subject, $result)
{
return 123.45;
}
}
?>
It all looks OK but it's not changing the price in the admin.
Any ideas?
(all cache etc cleaned, content deployed, etc etc)