コード例 #1
0
ファイル: CollectionProvider.php プロジェクト: aiesh/magento2
 /**
  * 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;
 }
コード例 #2
0
 public function testGetConverterAbsent()
 {
     $this->assertEquals('Default Converter', $this->model->getConverter('absent'));
 }