I have create a plugin to change image object and call image url directly from AWS S3 instead of magento.
Function should be call on any page where product image will be loaded.
di.xml
<type name="Magento\Catalog\Block\Product\ImageBuilder">
<plugin name="add_product_object_to_image_data_array_new" type="<vendor>\<module>\Plugin\Block\Catalog\Product\ImageBuilder" sortOrder="100" disabled="false"/>
</type>
File: vendor\module\Plugin\Block\Catalog\Product\ImageBuilder.php
<?php
namespace <vendor>\<module>\Plugin\Block\Catalog\Product;
use Magento\Catalog\Model\Product;
class ImageBuilder
{
/**
* @param \Magento\Catalog\Block\Product\ImageBuilder $subject
* @param callable $proceed
*
* @return mixed
*/
public function aroundCreate(
\Magento\Catalog\Block\Product\ImageBuilder $subject,
callable $proceed
) {
echo "<pre>";
print_r("test");
exit;
return $proceed();
}
}
I tried to call plugin but nothing happening and it's calling core function only.
I tried :
- bin/magento setup:upgrade
- bin/magento setup:static-content:deploy -f
- bin/magento setup:di:compile
- bin/magento index:reindex
- bin/magento cache:flush
still nothing works. Any help would be appreciated.