本文整理匯總了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();
}