_init('sales_sequence_profile', 'profile_id'); } /** * @var ProfileFactory */ protected $profileFactory; /** * @param DatabaseContext $context * @param ProfileFactory $profileFactory * @param string $connectionName */ public function __construct( DatabaseContext $context, ProfileFactory $profileFactory, $connectionName = null ) { $this->profileFactory = $profileFactory; parent::__construct($context, $connectionName); } /** * Load active profile * * @param int $metadataId * @return \Magento\SalesSequence\Model\Profile * @throws \Magento\Framework\Exception\LocalizedException */ public function loadActiveProfile($metadataId) { $profile = $this->profileFactory->create(); $connection = $this->getConnection(); $bind = ['meta_id' => $metadataId]; $select = $connection->select() ->from($this->getMainTable(), ['profile_id']) ->where('meta_id = :meta_id') ->where('is_active = 1'); $profileId = $connection->fetchOne($select, $bind); if ($profileId) { $this->load($profile, $profileId); } return $profile; } }