<?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="Magenticians_Moduleproduct" setup_version="1.0.1"> </module> </config>
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Magenticians_Moduleproduct', __DIR__ );
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Catalog\Model\Product" type="Magenticians\Moduleproduct\Model\Catalog\Product" /> </config><preference for=””> Which Model to override. <preference type=””> Where to override.
<?php namespace Magenticians\Moduleproduct\Model\Catalog; class Product extends \Magento\Catalog\Model\Product { public function getName() { return $this->_getData(self::NAME) . ' + Demo Text'; } public function getSku() { return "123-Demo"; } }In the code above, I have overriden the product name and product SKU.
php bin/magento module:enable Magenticians_Moduleproduct php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento cache:clean php bin/magento cache:flushNow it’s time to check results! Go to the product page and you should see this:
Looking for the most reliable hosting platform?
Then, do check out Managed Magento hosting and avail Free Trial for 3 Days.
In the highly competitive modern workplace, trust, and employee loyalty are crucial factors for long-term… Read More
In the ever-evolving world of small business developing and implementing effective marketing strategies is critical to… Read More
With one of the highest internet penetration rates, the UAE has set out to revolutionize… Read More
Artificial Intelligence (AI) has been continually evolving, leading to remarkable advancements in various industries. Among… Read More
Extensions, extensions and lots of extensions. We all love extensions, don’t we? After all, extensions… Read More
Software quality is crucial to a firm's success across industries in the quickly changing digital… Read More
View Comments
I tried override model in magento 2.1.8 i got the output but the design is not working
Have you run all the CLI commands?
Have you run all the CLI commands?
I try to run any command here, I got blow error,
[Zend_Db_Adapter_Exception]
SQLSTATE[HY000] [2002] No such file or directory
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
and not able to resolve this.