Convert an array of products to an array of preview items.

@param \Magento\Catalog\Model\ResourceModel\Product[] $products Product list.

@return array
171681
private function preparePreviewItems($products = [])
    {
        $items = [];

        foreach ($products as $product) {
            $items[$product->getId()] = $this->itemFactory->getData($product);
        }

        return array_values($items);
    }
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;
    }
1150602
private function get_cache_key( array $products ) {
		$products_string = '';

		foreach ( $products as $product ) {
			$products_string .= $product->get_item_name();
		}

		return md5( self::YST_SEO_SUPPORT_IDENTIFY . $products_string );
	}
849864
protected function prepareProductsCompare(array &$products)
    {
        foreach ($products as $product_id => &$product) {
            $product['field'] = $this->product_field->getList($product_id);
            $this->setItemProductFields($product, $this->image, $this->product_class);
        }
    }
1084248
public function prepareCollection(ProductCollection $collection)
    {
        $terms = $this->getQueryText();

        $collection->setSearchQuery($terms);

        return $collection;
    }
1055301
public static function shakeFor(Collection $products) : Collection
	{
		$suggestions = new static($key = 'all');

		$suggestions->products = $products;

		$suggestions->excluding($products);

		return $suggestions->suggestFor($key);
	}
632024
private function getFilterArray(array $request, \Magento\Catalog\Model\Product $product)
    {
        $filterArray = [];
        $attributes = $this->eavConfig->getEntityAttributes(\Magento\Catalog\Model\Product::ENTITY, $product);

        foreach ($request as $code => $value) {
            if (array_key_exists($code, $attributes)) {
                $attribute = $attributes[$code];
                if ($this->canReplaceImageWithSwatch($attribute)) {
                    $filterArray[$code] = $value;
                }

                if (isset($filterArray[$code]) && !is_array($filterArray[$code])) {
                    $filterArray[$code] = [$filterArray[$code]];
                }

                if ($attribute->getId() && $this->canReplaceImageWithSwatch($attribute)) {
                    $filterArray[$code][] = $this->swatchHelperData->getOptionIds($attribute, $value);
                }
            }
        }

        return $filterArray;
    }
810572
public function toArray()
	{
		$list = parent::toArray();

		$list['product.stock.productid'] = $this->getProductId();
		$list['product.stock.warehouseid'] = $this->getWarehouseId();
		$list['product.stock.stocklevel'] = $this->getStocklevel();
		$list['product.stock.dateback'] = $this->getDateBack();

		return $list;
	}
850820
protected function prepareListCart(array &$items)
    {
        foreach ($items as &$item) {
            $this->setItemUrlEntity($item, $this->store, 'product');
        }
    }
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;
    }
659826
protected function prepareProduct(array &$product)
    {
        $options = array(
            'store_id' => $product['store_id'],
            'product_id' => $product['product_id']
        );

        $product['related'] = $this->product->getRelated($options);
        $product['price'] = $this->price->decimal($product['price'], $product['currency']);

        $this->setSkuCombinationProduct($product);
        $this->setItemAlias($product, 'product', $this->alias);
        $this->setItemImages($product, 'product', $this->image);
        $this->setItemTranslation($product, 'product', $this->translation_entity);

        if (!empty($product['images'])) {
            foreach ($product['images'] as &$file) {
                $this->setItemTranslation($file, 'file', $this->translation_entity);
            }
        }
    }
886885
public function addProduct(\Sulu\Bundle\ProductBundle\Entity\Product $products)
    {
        $this->products[] = $products;

        return $this;
    }
1326666
public function single($product)
    {
        $entry = new Entry($product);

        $entry
            ->field('id')
            ->field('product_id')
            ->field('price')
            ->field('sale_price')
            ->field('quantity')

            ->relationshipField('product', 'Subbly\\Presenter\\V1\\ProductPresenter')

            ->dateField('created_at')
            ->dateField('updated_at')
        ;

        return $entry->toArray();
    }
1032886
public function edit(Product $product)
    {
        $product->categories;
        $attributes = Collection::make([]);

        $properties = Property::all();
        $usedForAllProductProperties = Property::whereUseForAllProducts(1)->get();

        if ($product->type == 'VARIATION') {
            $attributes = AttributeDropdownOption::all()->pluck('name', 'id');
        }

        return view('avored-framework::product.edit')
            ->with('product', $product)
            ->with('model', $product)
            ->with('propertyOptions', $properties)
            ->with('usedForAllProductProperties', $usedForAllProductProperties)
            ->with('attributeOptions', $attributes);
    }
484161
private function markProductsAsSynced($products, $syncDomainsCount)
    {

        $syncProducts = $this->SyncProduct->findAllSyncProducts($this->AppAuth->getManufacturerId());

        foreach ($products as $product) {
            $syncCount = 0;
            $preparedSyncProducts = [];

            foreach ($syncProducts as $syncProduct) {
                if ($syncProduct->dash_separated_local_product_id === $product->id_product) {
                    $syncCount++;
                    $preparedSyncProducts[] = [
                        'domain' => $syncProduct->sync_domain->domain,
                        'name' => 'Name wird nach Login angezeigt...',
                        'remoteProductId' => $syncProduct->dash_separated_remote_product_id
                    ];
                }
            }

            if ($syncCount > 0) {
                $product->prepared_sync_products = $preparedSyncProducts;
            }
        }

        return $products;
    }
1160957
public function createArray(array $items): Array_
    {
        $arrayItems = [];

        foreach ($items as $item) {
            $arrayItems[] = $this->createArrayItem($item);
        }

        return new Array_($arrayItems);
    }
441737
public function process(array $items)
    {
        foreach ($items as $key => $item) {
            $items[$key] = $this->removeStyle($item);
        }

        return $items;
    }