Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Profile.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\SalesSequence\Model\Meta as ModelMeta;
10 use Magento\SalesSequence\Model\ProfileFactory;
11 
19 {
25  protected $_eventPrefix = 'sales_sequence_profile';
26 
32  protected function _construct()
33  {
34  $this->_init('sales_sequence_profile', 'profile_id');
35  }
36 
40  protected $profileFactory;
41 
47  public function __construct(
48  DatabaseContext $context,
49  ProfileFactory $profileFactory,
50  $connectionName = null
51  ) {
52  $this->profileFactory = $profileFactory;
53  parent::__construct($context, $connectionName);
54  }
55 
63  public function loadActiveProfile($metadataId)
64  {
65  $profile = $this->profileFactory->create();
66  $connection = $this->getConnection();
67  $bind = ['meta_id' => $metadataId];
68  $select = $connection->select()
69  ->from($this->getMainTable(), ['profile_id'])
70  ->where('meta_id = :meta_id')
71  ->where('is_active = 1');
72 
73  $profileId = $connection->fetchOne($select, $bind);
74 
75  if ($profileId) {
76  $this->load($profile, $profileId);
77  }
78  return $profile;
79  }
80 }
__construct(DatabaseContext $context, ProfileFactory $profileFactory, $connectionName=null)
Definition: Profile.php:47
load(\Magento\Framework\Model\AbstractModel $object, $value, $field=null)
Definition: AbstractDb.php:339
$connection
Definition: bulk.php:13