Overriding model file is not working in Magento 2.2.5

Overriding model file is not working in Magento 2.2.5



I tried to override model, but it is not working. I need to override:



MagentoCatalogModelProductAttributeBackendPrice to
PawanCatalogModelRewriteProductAttributeBackendPrice



But it not working.



My di.xml path Pawan/Catalog/etc/di.xml:


di.xml


Pawan/Catalog/etc/di.xml



<?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="MagentoCatalogModelProductAttributeBackendPrice" typr="PawanCatalogModelRewriteProductAttributeBackendPrice" />
</config>


<?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="MagentoCatalogModelProductAttributeBackendPrice" typr="PawanCatalogModelRewriteProductAttributeBackendPrice" />
</config>



My model file:


<?php
namespace PawanCatalogModelRewriteProductAttributeBackend;

class Price extends MagentoCatalogModelProductAttributeBackendPrice

public function afterSave($object)

$writer = new ZendLogWriterStream(BP . '/var/log/importmissingorders.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$logger->info("custom model");

/** @var $attribute MagentoCatalogModelResourceModelEavAttribute */
$attribute = $this->getAttribute();
$attributeCode = $attribute->getAttributeCode();
$value = $object->getData($attributeCode);

// $value may be passed as null to unset the attribute
if ($value === null



It is still executing the core file only.



What am I doing wrong?





did you already clear cache or setup:upgrade or di:compile ?
– mrfizh
Sep 3 at 15:13





What do you mean by "But it working." and "My di.xml local Pawan/Catalog/etc/di.xml"?
– Peter Mortensen
Sep 3 at 16:57


di.xml


Pawan/Catalog/etc/di.xml




1 Answer
1



Change typr,


typr


<preference for="MagentoCatalogModelProductAttributeBackendPrice" typr="PawanCatalogModelRewriteProductAttributeBackendPrice" />



to type:


type


<preference for="MagentoCatalogModelProductAttributeBackendPrice" type="PawanCatalogModelRewriteProductAttributeBackendPrice" />





yes in server logs i found it typo mistake
– Pawankumar
Sep 3 at 15:30



Thanks for contributing an answer to Magento Stack Exchange!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế