<?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.
Your greatest possible competitive advantage can be your clients and the interactions they have with… Read More
Digital marketing KPIs are measurable values that marketing teams use to track progress toward desired… Read More
In today's digital age, fraud poses a significant threat to businesses of all sizes. As… Read More
Financial crimes continue to evolve and proliferate in our increasingly digital, global economy. From complex… Read More
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
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.