![]() 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/extmag/shiplab/Model/ResourceModel/ConfigurationScope/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Model\ResourceModel\ConfigurationScope; use Exception; use Extmag\Shiplab\Model\ResourceModel\ConfigurationScope; use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; class Collection extends AbstractCollection { protected $_idFieldName = 'entity_id'; protected function _construct() { $this->_init( \Extmag\Shiplab\Model\ConfigurationScope::class, ConfigurationScope::class ); } public function addScopeFilter($storeId, $directionId, $countryId) { if (($storeId == null && $directionId != null) || ($directionId == null && $countryId != null) ) { throw new Exception(__('The scope store or direction or country is not present')); } if ($storeId != null) { $conf_store_table = $this->getTable("extmag_configuration_store"); $this->getSelect() ->join( ['store' => $conf_store_table], 'main_table.store = store.entity_id AND FIND_IN_SET("' . ((int)$storeId) . '", store.stores_ids)' ); if ($directionId != null) { $conf_direction_table = $this->getTable("extmag_configuration_direction"); $this->getSelect() ->join( ['direction' => $conf_direction_table], 'main_table.direction = direction.entity_id AND store.entity_id = direction.store_id AND FIND_IN_SET("' . $directionId . '", direction.directions_ids)' ); if ($countryId != null) { $conf_country_table = $this->getTable("extmag_configuration_country"); $this->getSelect() ->join( ['country' => $conf_country_table], 'main_table.country = country.entity_id AND direction.entity_id = country.direction_id AND FIND_IN_SET("' . $countryId . '", country.countries_ids)' ); } } } $this->getSelect()->limit(1); return $this; } }