本文整理汇总了PHP中Sylius\Component\Core\Model\ProductInterface::getMasterVariant方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getMasterVariant方法的具体用法?PHP ProductInterface::getMasterVariant怎么用?PHP ProductInterface::getMasterVariant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Core\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getMasterVariant方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_adds_single_item_by_customer(FactoryInterface $orderItemFactory, OrderInterface $order, OrderItemInterface $item, OrderItemQuantityModifierInterface $itemQuantityModifier, ProductInterface $product, SharedStorageInterface $sharedStorage, ProductVariantInterface $variant, ObjectManager $objectManager)
{
$sharedStorage->get('order')->willReturn($order);
$orderItemFactory->createNew()->willReturn($item);
$product->getMasterVariant()->willReturn($variant);
$product->getPrice()->willReturn(1234);
$itemQuantityModifier->modify($item, 1)->shouldBeCalled();
$item->setVariant($variant)->shouldBeCalled();
$item->setUnitPrice(1234)->shouldBeCalled();
$order->addItem($item)->shouldBeCalled();
$objectManager->flush()->shouldBeCalled();
$this->theCustomerBoughtSingle($product);
}
示例2: productBelongsToTaxCategory
/**
* @Given /^([^"]+) belongs to ("[^"]+" tax category)$/
*/
public function productBelongsToTaxCategory(ProductInterface $product, TaxCategoryInterface $taxCategory)
{
$product->getMasterVariant()->setTaxCategory($taxCategory);
$this->objectManager->flush();
}
示例3: configureProductPricingCalculator
/**
* @param ProductInterface $product
* @param array $data
*/
private function configureProductPricingCalculator(ProductInterface $product, array $data)
{
$product->getMasterVariant()->setPricingCalculator($data['pricing calculator']);
if (!isset($data['calculator configuration']) || '' === $data['calculator configuration']) {
throw new \InvalidArgumentException('You must set chosen calculator configuration');
}
$product->getMasterVariant()->setPricingConfiguration($this->getPricingCalculatorConfiguration($data));
}
示例4: addMasterVariant
/**
* Adds master variant to product.
*
* @param ProductInterface $product
* @param string $sku
*/
protected function addMasterVariant(ProductInterface $product, $sku = null)
{
$variant = $product->getMasterVariant();
$variant->setProduct($product);
$variant->setPrice($this->faker->randomNumber(4));
$variant->setSku(null === $sku ? $this->getUniqueSku() : $sku);
$variant->setAvailableOn($this->faker->dateTimeThisYear);
$variant->setOnHand($this->faker->randomNumber(1));
$variant->setTaxCategory($this->getTaxCategory('Taxable goods'));
$productName = explode(' ', $product->getName());
$image = clone $this->getReference('Sylius.Image.' . strtolower($productName[0]));
$variant->addImage($image);
$this->setReference('Sylius.Variant-' . $this->totalVariants, $variant);
++$this->totalVariants;
$product->setMasterVariant($variant);
}
示例5: theCustomerBoughtSingle
/**
* @Given the customer bought single :product
*/
public function theCustomerBoughtSingle(ProductInterface $product)
{
/** @var OrderInterface $order */
$order = $this->sharedStorage->get('order');
/** @var OrderItemInterface $item */
$item = $this->orderItemFactory->createNew();
$item->setVariant($product->getMasterVariant());
$item->setUnitPrice($product->getPrice());
$this->itemQuantityModifier->modify($item, 1);
$order->addItem($item);
$this->objectManager->flush();
}
示例6: orderItemShouldNotExistInTheRegistry
/**
* @Then the order item with product :product should not exist
*/
public function orderItemShouldNotExistInTheRegistry(ProductInterface $product)
{
$orderItems = $this->orderItemRepository->findBy(['variant' => $product->getMasterVariant()]);
expect($orderItems)->toBe([]);
}
示例7: theCustomerBoughtSingleUsing
/**
* @Given the customer bought single :product using :coupon coupon
*/
public function theCustomerBoughtSingleUsing(ProductInterface $product, CouponInterface $coupon)
{
$order = $this->addSingleProductVariantToOrder($product->getMasterVariant(), $product->getPrice());
$order->setPromotionCoupon($coupon);
$this->orderRecalculator->recalculate($order);
$this->objectManager->flush();
}
示例8:
function it_throws_an_exception_if_order_item_still_exist(RepositoryInterface $orderItemRepository, ProductInterface $product, ProductVariantInterface $productVariant, OrderItemInterface $orderItem)
{
$product->getMasterVariant()->willReturn($productVariant);
$orderItemRepository->findBy(['variant' => $productVariant])->willReturn([$orderItem]);
$this->shouldThrow(NotEqualException::class)->during('orderItemShouldNotExistInTheRegistry', [$product]);
}