![]() 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/Ecombricks/InventoryConfig/Model/ResourceModel/Config/Data/ |
<?php /** * Copyright © eComBricks. All rights reserved. * See LICENSE.txt for license details. */ namespace Ecombricks\InventoryConfig\Model\ResourceModel\Config\Data; /** * Config data resource source trait */ trait SourceTrait { /** * Check unique * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _checkUnique(\Magento\Framework\Model\AbstractModel $object) { $connection = $this->getConnection(); $select = $connection->select() ->from($this->getMainTable(), [$this->getIdFieldName()]) ->where('scope = :scope') ->where('scope_id = :scope_id') ->where('path = :path'); $bind = [ 'scope' => $object->getScope(), 'scope_id' => $object->getScopeId(), 'path' => $object->getPath(), ]; $sourceCode = $object->getSourceCode(); if ($sourceCode) { $select->where('source_code = :source_code'); $bind['source_code'] = $sourceCode; } else { $select->where('source_code IS NULL'); } $configId = $connection->fetchOne($select, $bind); if ($configId) { $object->setId($configId); } return $this; } }