To create dynamic names of product, You can create plugin
which will alter/modify original product name dynamically.
create a simple module say Pawan_SamplePlugin
app/code/Pawan/SamplePlugin/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Pawan_SamplePlugin',
__DIR__
);
app/code/Pawan/SamplePlugin/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Pawan_SamplePlugin" setup_version="1.0.0" />
</config>
app/code/Pawan/SamplePlugin/etc/di.xml
<?xml version="1.0" encoding="UTF-8"?>
<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="DynamicSetName" type="Pawan\SamplePlugin\Plugin\ProductName" disabled="false" />
</type>
</config>
app/code/Pawan/SamplePlugin/Plugin/ProductName.php
<?php
namespace Pawan\SamplePlugin\Plugin;
class ProductName
{
public function afterGetName(\Magento\Catalog\Model\Product $subject, $result)
{
return '|@@' . $result . '|##';
}
}
You can Update afterGetName
as per your requirement and update product name accordingly.
Hope above will help!