link-in - רשומות קוד

חפש את הקוד שלך >

דריסת פונקציה – preference – di.xml

Vandor/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="Magento\Catalog\Model\Product" type="Anagal\NewPrice\Model\Catalog\Product" />
</config>
הדריסה של הקובץ , האתגר זה למצוא את הפונקציה הרלוונטים אחרי זה רק מתייחסים לנתיב הרלוונטי : Product.php
<?php

namespace Anagal\NewPrice\Model\Catalog;

class Product extends \Magento\Catalog\Model\Product
{
    /**
     * Get product name
     *
     * @return string
     * @codeCoverageIgnoreStart
     */
    public function getName()
    {
        // logging to test override
        $logger = \Magento\Framework\App\ObjectManager::getInstance()->get('\Psr\Log\LoggerInterface');
        $logger->debug('getName on');

        return $this->_getData(self::NAME);
    }
    public function getPrice()
    {
        // logging to test override
        $logger = \Magento\Framework\App\ObjectManager::getInstance()->get('\Psr\Log\LoggerInterface');
        $logger->debug('getPrice on');
        return $this->_getData(self::NAME);
//        if ($this->_calculatePrice || !$this->getData(self::PRICE)) {
//            return $this->getPriceModel()->getPrice($this);
//        } else {
//            return $this->getData(self::PRICE);
//        }
    }
}
?>