![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-weee/Model/ResourceModel/Attribute/Backend/Weee/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Weee\Model\ResourceModel\Attribute\Backend\Weee; /** * Catalog product WEEE tax backend attribute model * * @author Magento Core Team <[email protected]> */ class Tax extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * @var \Magento\Store\Model\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param string $connectionName */ public function __construct( \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, $connectionName = null ) { $this->_storeManager = $storeManager; parent::__construct($context, $connectionName); } /** * Defines main resource table and table identifier field * * @return void */ protected function _construct() { $this->_init('weee_tax', 'value_id'); } /** * Load product data * * @param \Magento\Catalog\Model\Product $product * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute * @return array */ public function loadProductData($product, $attribute) { $select = $this->getConnection()->select()->from( $this->getMainTable(), ['website_id', 'country', 'state', 'value'] )->where( 'entity_id = ?', (int)$product->getId() )->where( 'attribute_id = ?', (int)$attribute->getId() ); if ($attribute->isScopeGlobal()) { $select->where('website_id = ?', 0); } else { $storeId = $product->getStoreId(); if ($storeId) { $select->where( 'website_id IN (?)', [0, $this->_storeManager->getStore($storeId)->getWebsiteId()] ); } } return $this->getConnection()->fetchAll($select); } /** * Delete product data * * @param \Magento\Catalog\Model\Product $product * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute * @return $this */ public function deleteProductData($product, $attribute) { $where = ['entity_id = ?' => (int)$product->getId(), 'attribute_id = ?' => (int)$attribute->getId()]; $connection = $this->getConnection(); if (!$attribute->isScopeGlobal()) { $storeId = $product->getStoreId(); if ($storeId) { $where['website_id IN(?)'] = [0, $this->_storeManager->getStore($storeId)->getWebsiteId()]; } } $connection->delete($this->getMainTable(), $where); return $this; } /** * Insert product data * * @param \Magento\Catalog\Model\Product $product * @param array $data * @return $this */ public function insertProductData($product, $data) { $data['entity_id'] = (int)$product->getId(); $this->getConnection()->insert($this->getMainTable(), $data); return $this; } }