/** * Set channels. * * @param ProductInterface $product * @param array $channelCodes */ protected function setChannels(ProductInterface $product, array $channelCodes) { foreach ($channelCodes as $code) { $product->addChannel($this->getReference('Sylius.Channel.' . $code)); } }
/** * @param ProductInterface $product * @param array $options */ private function createRelations(ProductInterface $product, array $options) { foreach ($options['taxons'] as $taxon) { $product->addTaxon($taxon); } foreach ($options['channels'] as $channel) { $product->addChannel($channel); } foreach ($options['product_options'] as $option) { $product->addOption($option); } foreach ($options['product_attributes'] as $attribute) { $product->addAttribute($attribute); } }
/** * @Given /^(this product) is also priced at ("[^"]+") in ("[^"]+" channel)$/ */ public function thisProductIsAlsoPricedAtInChannel(ProductInterface $product, $price, ChannelInterface $channel) { $product->addChannel($channel); /** @var ProductVariantInterface $productVariant */ $productVariant = $this->defaultVariantResolver->getVariant($product); /** @var ChannelPricingInterface $channelPricing */ $channelPricing = $this->channelPricingFactory->createNew(); $channelPricing->setPrice($price); $channelPricing->setChannel($channel); $productVariant->addChannelPricing($channelPricing); $this->objectManager->flush(); }