- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2016
04:14 AM
10-09-2016
04:14 AM
Get data from another model
I overwrote model:
<?php namespace Pagseguro\Magento2\Price; /** * Special price model */ class SpecialPrice extends \Magento\Catalog\Pricing\Price\SpecialPrice { /** * Returns special price * * @return float */ public function getSpecialPrice() { $specialPrice = $this->product->getSpecialPrice(); if ($specialPrice !== null && $specialPrice !== false && !$this->isPercentageDiscount()) { $specialPrice = $this->priceCurrency->convertAndRound($specialPrice); } return 3.11; } }
But i want additionally, get data from my new model:
<?php namespace Pagseguro\Magento2\Model; class Items extends \Magento\Framework\Model\AbstractModel { /** * Constructor * * @return void */ protected function _construct() { parent::_construct(); $this->_init('Pagseguro\Magento2\Model\Resource\Items'); } }
<?php namespace Pagseguro\Magento2\Model\Resource; class Items extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Model Initialization * * @return void */ protected function _construct() { $this->_init('pagseguro_magento2_items', 'id'); } }
<?php namespace Pagseguro\Magento2\Model\Resource\Items; class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Define resource model * * @return void */ protected function _construct() { $this->_init('Pagseguro\Magento2\Model\Items', 'Pagseguro\Magento2\Model\Resource\Items'); } }
How me to do it?
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017
04:11 PM
02-13-2017
04:11 PM
Re: Get data from another model
Can you please share end goal for overriding SpecialPrice class?