Returns an array of products indexed by a class ID
@param array $products
@return array
546039
protected function reindexProductsCompare(array $products)
    {
        $prepared = array();

        foreach ($products as $product_id => $product) {
            $prepared[$product['product_class_id']][$product_id] = $product;
        }

        return $prepared;
    }
883401
protected function bootstrap(array $classes): array
    {
        foreach ($classes as $index => $class) {
            $classes[$index] = $this->app->make($class)->bootstrap();
        }

        return $classes;
    }
719106
protected function getLr($ids)
    {
        $class = $this->className;
        return $class::find()
            ->select(['id', $this->leftAttribute, $this->rightAttribute])
            ->where(['id' => $ids])
            ->indexBy('id')
            ->asArray(true)
            ->all();
    }
576613
public function getMulti(array $keys)
    {
        $results = array();
        foreach ($keys as $key) {
            $results[$key] = $this->get($key);
        }
        return $results;
    }
408550
protected function filterFields(array $fields)
    {
        if ($requested = $this->getOwnFields()) {
            $fields = array_intersect_key($fields, array_flip($requested));
        }

        return $fields;
    }
170583
protected function indexProductTranslations(array $product)
    {
        if (empty($product['translation'])) {
            return false;
        }

        $indexed = 0;

        foreach ($product['translation'] as $language => $translation) {
            $translation += $product;
            $snippet = $this->search->getSnippet($translation, $language);
            $indexed += (int) $this->search->setIndex($snippet, 'product', $product['product_id'], $language);
        }

        return $indexed > 0;
    }
613895
protected function getProductIds( array $productItems )
	{
		$prodIds = [];

		foreach( $productItems as $product )
		{
			if( $product->getType() === 'select' ) {
				$prodIds = array_merge( $prodIds, array_keys( $product->getRefItems( 'product', 'default', 'default' ) ) );
			}
		}

		return $prodIds;
	}
18523
public function getList(array $options)
    {
        $result = null;
        $this->hook->attach('product.related.list.before', $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $result = array();

        if (isset($options['product_id'])) {

            $sql = 'SELECT item_product_id FROM product_related WHERE product_id=?';

            if (!empty($options['limit'])) {
                $sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit']));
            }

            $result = $this->db->fetchColumnAll($sql, array($options['product_id']));
        }

        $this->hook->attach('product.related.list.after', $options, $result, $this);
        return $result;
    }
28743
public function getList(array $options = array())
    {
        $result = null;
        $this->hook->attach('product.class.list.before', $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $sql = 'SELECT pc.*';

        if (!empty($options['count'])) {
            $sql = 'SELECT COUNT(pc.product_class_id)';
        }

        $sql .= ' FROM product_class pc WHERE pc.product_class_id IS NOT NULL';

        $conditions = array();

        if (isset($options['title'])) {
            $sql .= ' AND pc.title LIKE ?';
            $conditions[] = "%{$options['title']}%";
        }

        if (isset($options['status'])) {
            $sql .= ' AND pc.status=?';
            $conditions[] = (int) $options['status'];
        }

        $allowed_order = array('asc', 'desc');
        $allowed_sort = array('title', 'status', 'product_class_id');

        $sql .= ' GROUP BY pc.product_class_id';

        if (isset($options['sort'])
            && in_array($options['sort'], $allowed_sort)
            && isset($options['order'])
            && in_array($options['order'], $allowed_order)) {
            $sql .= " ORDER BY pc.{$options['sort']} {$options['order']}";
        } else {
            $sql .= ' ORDER BY pc.title ASC';
        }

        if (!empty($options['limit'])) {
            $sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit']));
        }

        if (empty($options['count'])) {
            $result = $this->db->fetchAll($sql, $conditions, array('index' => 'product_class_id'));
        } else {
            $result = (int) $this->db->fetchColumn($sql, $conditions);
        }

        $this->hook->attach('product.class.list.after', $options, $result, $this);
        return $result;
    }
998373
protected function getListProductClass()
    {
        $id = $this->getParam(0);

        if (!isset($id)) {
            return $this->product_class->getList(array('limit' => $this->getLimit()));
        }

        if (!is_numeric($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $result = $this->product_class->get($id);

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($result);
    }
25915
protected function attachFields(array &$product)
    {
        if (empty($product)) {
            return $product;
        }

        $product['field'] = $this->product_field->getList($product['product_id']);

        if (empty($product['field']['option'])) {
            return $product;
        }

        foreach ($product['field']['option'] as &$field_values) {
            $field_values = array_unique($field_values);
        }

        return $product;
    }
548353
public function setProducts(array $products)
    {
        $this->products = array_values(array_filter($products, function ($product): bool {
            return $product instanceof Product;
        }));
        return $this;
    }
1138555
private function retrieveProductTypesMap()
    {
        $productTypeMap = [];
        LoadProductTypes::processProductTypesFixtures(
            function (\DOMElement $element) use (&$productTypeMap) {
                $productTypeMap[$element->getAttribute('key')] = $element->getAttribute('id');
            }
        );

        return $productTypeMap;
    }
28046
public function getProductTaxClasses()
    {
        /** @var \Magento\Tax\Model\ResourceModel\TaxClass\Collection $taxCollection */
        $classes       = [];
        $taxCollection = $this->taxClass->getCollection();
        $taxCollection->setClassTypeFilter(ClassModel::TAX_CLASS_TYPE_PRODUCT);

        /** @var ClassModel $tax */
        foreach ($taxCollection as $tax) {
            $classes[] = [
                'id'  => $tax->getId(),
                'key' => $tax->getClassName()
            ];
        }

        return $classes;
    }
1122335
public function getProductsAjax()
    {
        if (!$this->access('product')) {
            return array('error' => $this->text('No access'));
        }

        $params = array(
            'status' => $this->getPosted('status'),
            'title_sku' => $this->getPosted('term'),
            'store_id' => $this->getPosted('store_id'),
            'limit' => array(0, $this->config('autocomplete_limit', 10))
        );

        $products = (array) $this->sku->getList($params);

        $product_ids = array();

        foreach ($products as $product) {
            $product_ids[] = $product['product_id'];
        }

        $options = array(
            'entity' => 'product',
            'entity_id' => $product_ids,
            'template_item' => 'backend|content/product/suggestion'
        );

        foreach ($products as &$product) {
            $this->setItemThumb($product, $this->image, $options);
            $this->setItemPriceFormatted($product, $this->price);
            $this->setItemRendered($product, array('item' => $product), $options);
        }

        return $products;
    }
206635
protected function getProducts( array $codes, array $domains )
	{
		$result = [];
		$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );

		$search = $manager->createSearch();
		$search->setConditions( $search->compare( '==', 'product.code', $codes ) );
		$search->setSlice( 0, count( $codes ) );

		foreach( $manager->searchItems( $search, $domains ) as $item ) {
			$result[$item->getCode()] = $item;
		}

		return $result;
	}
757064
protected function getSelectedProducts()
    {
        $products = $this->getProductsRelated();
        if (!is_array($products)) {
            $products = array_keys($this->getSelectedRelatedProducts());
        }

        return $products;
    }