本文整理汇总了PHP中Sylius\Component\Core\Model\ProductInterface::getChannels方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getChannels方法的具体用法?PHP ProductInterface::getChannels怎么用?PHP ProductInterface::getChannels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Core\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getChannels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: customersHavePlacedOrdersForTotalOfMostlyProduct
/**
* @Given :numberOfCustomers customers have placed :numberOfOrders orders for total of :total mostly :product product
* @Given then :numberOfCustomers more customers have placed :numberOfOrders orders for total of :total mostly :product product
*/
public function customersHavePlacedOrdersForTotalOfMostlyProduct($numberOfCustomers, $numberOfOrders, $total, ProductInterface $product)
{
$customers = $this->generateCustomers($numberOfCustomers);
$sampleProductVariant = $product->getVariants()->first();
$total = $this->getPriceFromString($total);
for ($i = 0; $i < $numberOfOrders; $i++) {
$order = $this->createOrder($customers[rand(0, $numberOfCustomers - 1)], '#' . uniqid(), $product->getChannels()->first());
$order->setState(OrderInterface::STATE_NEW);
$this->applyPaymentTransitionOnOrder($order, PaymentTransitions::TRANSITION_COMPLETE);
$price = $i === $numberOfOrders - 1 ? $total : rand(1, $total);
$total -= $price;
$item = $this->orderItemFactory->createNew();
$item->setVariant($sampleProductVariant);
$item->setUnitPrice($price);
$this->itemQuantityModifier->modify($item, 1);
$order->addItem($item);
$this->orderRepository->add($order);
}
}