How can i write below script in magento 2
class NameSpace_Notification_Model_App extends Mage_Core_Model_Config_Data
{
public function save(){ }
}
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityHow can i write below script in magento 2
class NameSpace_Notification_Model_App extends Mage_Core_Model_Config_Data
{
public function save(){ }
}
in magento 2 you can write code
<?php
namespace NameSpace_Notification_Model;
class App extends \Magento\Config\Model\Config
{
public function save(){ }
}
Note::your __construct must be same with \Magento\Config\Model\Config __construct
You have to write like this,
namespace {NameSpace}\{Module}\Model;
class App extends \Magento\Config\Model\Config
{
public function __construct(
\Magento\Framework\App\Config\ReinitableConfigInterface $config,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Config\Model\Config\Structure $configStructure,
\Magento\Framework\DB\TransactionFactory $transactionFactory,
\Magento\Config\Model\Config\Loader $configLoader,
\Magento\Framework\App\Config\ValueFactory $configValueFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = array()
) {
parent::__construct($config, $eventManager, $configStructure, $transactionFactory, $configLoader, $configValueFactory, $storeManager, $data);
}
public function save(){ }
...
}
and in your etc/di.xml
file you have to override
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Config\Model\Config" type="{NameSpace}\{ModuleName}\Model\{Your_Model_File}" />
</config>
You can also refer this url.
After that you have to recompile.