Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PositionResolver.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
14 {
20  protected function _construct()
21  {
22  $this->_init('catalog_product_entity', 'entity_id');
23  }
24 
31  public function getPositions(int $categoryId): array
32  {
33  $connection = $this->getConnection();
34 
35  $select = $connection->select()->from(
36  ['cpe' => $this->getTable('catalog_product_entity')],
37  'entity_id'
38  )->joinLeft(
39  ['ccp' => $this->getTable('catalog_category_product')],
40  'ccp.product_id=cpe.entity_id'
41  )->where(
42  'ccp.category_id = ?',
43  $categoryId
44  )->order(
45  'ccp.position ' . \Magento\Framework\DB\Select::SQL_ASC
46  );
47 
48  return array_flip($connection->fetchCol($select));
49  }
50 }
$connection
Definition: bulk.php:13
const SQL_ASC
Definition: Select.php:81