I have to change the type of an attribute from text to decimal. I used upgrade script below. But it is not working
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;
class UpgradeData implements UpgradeDataInterface
{
public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
}
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
if (version_compare($context->getVersion(), '1.0.1', '<')) {
$entityType = $eavSetup->getEntityTypeId('catalog_product');
$eavSetup->updateAttribute($entityType, 'as_low_as', 'frontend_input','decimal', null);
}
}
}
How can we update the attribute type of an existing attribute?