/** * Get product collection by link type * * @param \Magento\Catalog\Model\Product $product * @param string $type * @return array * @throws NoSuchEntityException */ public function getCollection(\Magento\Catalog\Model\Product $product, $type) { if (!isset($this->providers[$type])) { throw new NoSuchEntityException('Collection provider is not registered'); } $products = $this->providers[$type]->getLinkedProducts($product); $converter = $this->converterPool->getConverter($type); $output = []; foreach ($products as $item) { $output[$item->getId()] = $converter->convert($item); } return $output; }
public function testGetConverterAbsent() { $this->assertEquals('Default Converter', $this->model->getConverter('absent')); }