本文整理汇总了PHP中Sylius\Component\Core\Model\ProductInterface::addChannel方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::addChannel方法的具体用法?PHP ProductInterface::addChannel怎么用?PHP ProductInterface::addChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Core\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::addChannel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setChannels
/**
* 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));
}
}
示例2: createRelations
/**
* @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);
}
}
示例3: thisProductIsAlsoPricedAtInChannel
/**
* @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();
}