public function prepareAssociatedProducts(array $associatedProducts) { if ($this->magentoProduct->isSimpleType() || $this->magentoProduct->isDownloadableType()) { return array($this->magentoProduct->getProductId()); } if ($this->magentoProduct->isBundleType()) { $bundleAssociatedProducts = array(); foreach ($associatedProducts as $key => $productIds) { $bundleAssociatedProducts[$key] = reset($productIds); } return $bundleAssociatedProducts; } if ($this->magentoProduct->isConfigurableType()) { $configurableAssociatedProducts = array(); foreach ($associatedProducts as $productIds) { if (count($configurableAssociatedProducts) == 0) { $configurableAssociatedProducts = $productIds; } else { $configurableAssociatedProducts = array_intersect($configurableAssociatedProducts, $productIds); } } if (count($configurableAssociatedProducts) != 1) { throw new LogicException('There is no associated product found for configurable product.'); } return $configurableAssociatedProducts; } if ($this->magentoProduct->isGroupedType()) { return array_values($associatedProducts); } return array(); }