10

Basically, You need to override dependency file of priceCurrency interface by below way to change precision of price. You can set precision of price using below way, Just need to create a simple module for it, Create Rbj/PriceCurrency module under the app/code folder Magento. Create registration.php file, <?php \Magento\Framework\Component\...


7

You cannot override that class. Magento\Email\Model\AbstractTemplate is an abstract class and it never gets instantiated. Your code is correct but you don't see your method being called because your class is never instantiated. preferences work only for classes that get instantiated. You can do one of the following. - Create an around plugin for the method. ...


6

First of all, I will answer your question What is the best practices to override this php interface from the magento core files? From the basic knowledge, we cannot override an Interface. In Magento, it would be the same. Second, take a look at vendor/magento/module-catalog/etc/di.xml <preference for="Magento\Framework\Pricing\...


6

You can use the plugin to make changes in this function. Create following files in your custom module. app/code/Vendor/Module/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"> <type name="Magento\Email\...


5

Private function is not override: so you have better option that you can override getConfig method of Magento\Checkout\Model\DefaultConfigProvider and use 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"&...


3

Your di.xml is wrong if you want to override a class. In Magento there are two types of overriding: One is Plugin Another is preference PLUGIN: Is used for changing the behavior of a method. Syntax: <type name="{OriginalClass}"> <plugin name="{Name}" type="{PluginClasss}" sortOrder="{sortorder}"/> </type> Class preference: The ...


3

etc/di.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Catalog\Model\Layer\Category\FilterableAttributeList"> <plugin name="infinity_product_gallery" type="Namespace\Module\Plugin\FilterableAttributeList" /> ...


3

Here is complete working code you can use app/code/MyVendor/MyModule/etc/module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="MyVendor_MyModule" setup_version="1.0.0"></module&...


3

Instead of overriding getCustomerData function, create a plugin for getConfig function. app/code/Vendor/Module/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"> <type name="Magento\Checkout\Model\...


3

You could create another module to override the current one app/code/Vendor/Module/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="WebShopApps\MatrixRate\Model\Carrier\Matrixrate" type="...


3

This is because you are overriding the wrong class. Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector The class CommonTaxCollector is not used directly, Magento2 used a Tax class which overrides the CommonTaxCollector class. vendor/magento/module-tax/Model/Sales/Total/Quote/Tax.php Tax.php namespace Magento\Tax\Model\Sales\Total\Quote; .... class Tax ...


2

You have to add models node and follow below code <?xml version="1.0"?> <config> <modules> <Abc_CustomizeCustomers> <version>0.1.0</version> </Abc_CustomizeCustomers> </modules> <global> <models> <customer_resource> <rewrite> ...


2

Finally I found it. This is the class I had to override: \Magento\SalesRule\Model\ResourceModel\Rule\Collection public function setValidationFilter( $websiteId, $customerGroupId, $couponCode = '', $now = null, \Magento\Quote\Model\Quote\Address $address = null, $customerId = 0 ) { if (!$this->getFlag('validation_filter')) { ...


2

Use below code for 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="Magento\Sales\Model\Order\Pdf\Invoice" type="<Vendor>\<Module>\Model\Order\Pdf\Invoice"/> </config> I think ...


2

I think the best practice would be use Magento 2 plugin to apply your changes. 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"> <type name="Magento\Catalog\Api\Data\ProductInterface"> <...


2

drop your __construct method because you are not adding anything new to it compared to the original class. Also you may need to copy all of the private methods from the original class into yours. But to solve your problem.... you don't need to add weight to the select. Just edit the attribute in the backend and set the flag "Used in product listing" to "...


2

Can you do the below change in your di.xml file and confirm. <?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="Project\Catalog\Model\Product" /> </config>


2

Below Code Worked for me. If you check sales_invoice_item table here order_item_id column contains your Order items id. Vendor\Module\Model\Order\Pdf\Items\Invoice\DefaultInvoice.php <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Vendor\Module\Model\Order\Pdf\...


1

You need to override those private members as well. I can see that function getCustomerData() use customerRepository and customerSession which are defined as private members in parent class. Let me know if you still face any issue.


1

try: please remove the generated folder and cleaned cache after replacing a code <?php namespace Commercepundit\Dealerregistration\Model; use Magento\Customer\Api\AccountManagementInterface; use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\MailException; use Magento\Framework\...


1

Please replace your construct with below code and try: please remove generated folder and cleand cache after replacing code public function __construct( \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Framework\Math\Random $mathRandom, \Commercepundit\Core\Helper\Data $...


1

You need to change the module from Overrides_All.xml to Overrides_Customs.xml Use the below code in your model: <?php class Overrides_Customs_Model_Product extends Mage_Catalog_Model_Product { public function isNewProduct() { $newFromDate = Mage::getModel('catalog/product')->load($this->getID())->getNewsFromDate(); $...


1

The "processNewAndExistingImages" method is located in Magento\Catalog\Model\Product\Gallery\CreateHandler (that called on product creating), but it called on editind from Magento\Catalog\Model\Product\Gallery\UpdateHandler. So... To override "processNewAndExistingImages" in "CreateHandler" need to override it twice: make ...


1

it can easy Move/Copy to core module to - app/code/Magento/Wishlist List item edit composer.json and add "replace": { "magento/module-wishlist": "*" }, more info by link - https://www.integer-net.com/removing-unused-core-modules-from-magento-2-the-right-way/ run command SSH - composer update run command SSH - php bin/...


1

Create simple module and override model file. Step 1. Create a di.xml file in a following directory Company/CatalogImportExport/etc/ <?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\...


1

If you want to add weight attribute to collection, then you just enable this attribute "Used in Product Listing" from admin > Stores > Attributes > Product .Select weight attribute and then goto Storefront Properties.


1

You can do it via plugin. First of all you must create di.xml <config> <type name="Magento\Fedex\Model\Source\Generic"> <plugin name="your_plugin_name" type="YourVendor\YourModule\Plugin\GenericPlugin" sortOrder="10" /> </type> </config> Then you must create GenericPlugin.php and use after method. namespace ...


1

I assume your app\etc\modules\Grando_Producttype.xml is wrong, it should look like <?xml version="1.0"?> <config> <modules> <!-- missing node? --> <Grando_Producttype> <active>true</active> <codePool>local</codePool> </Grando_Producttype> </...


1

Magento does not allow you to rewrite abstract classes. The simplest solution would be copying the file to app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php and then editing the function as needed. The only other solution would be rewriting all the classes that extend the abstract class within your own custom module. To do so, you would need rewrite ...


1

To add SKU create a layout file sales_order_view.xml under Vendor/Module/view/adminhtml/layout <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <body> <referenceBlock name="column_name"> <action method="setTemplate"> <argument name="template" xsi:type="...


Only top voted, non community-wiki answers of a minimum length are eligible