<?php
/**
* Landofcoder
*
* NOTICE OF LICENSE
*
* This source file is subject to the Landofcoder.com license that is
* available through the world-wide-web at this URL:
* http://landofcoder.com/license
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Landofcoder
* @package Lofmp_TimeDiscount
* @copyright Copyright (c) 2017 Landofcoder (http://www.landofcoder.com/)
* @license http://www.landofcoder.com/LICENSE-1.0.html
*/
namespace Lofmp\TimeDiscount\Model\ResourceModel;
class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Store manager
*
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManager;
/**
* Construct
*
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param string|null $connectionName
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
$connectionName = null
) {
parent::__construct($context, $connectionName);
$this->_storeManager = $storeManager;
}
/**
* Initialize resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('lofmp_timediscount_product', 'id');
}
/**
* Perform operations after object load
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function _afterLoad(\Magento\Framework\Model\AbstractModel $object)
{
$objectData = $object->getData('data');
if ($objectData) {
$dataParsed = !empty($objectData) ? json_decode($objectData, true) : [];
$object->setData('time_product_data', $objectData);
$object->setData('data', $dataParsed);
$object->setData('time_discount_parsed', $dataParsed);
}
return parent::_afterLoad($object);
}
}
|