当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductInterface::getMasterVariant方法代码示例

本文整理汇总了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);
 }
开发者ID:starspire,项目名称:eventmanager,代码行数:13,代码来源:OrderContextSpec.php

示例2: productBelongsToTaxCategory

 /**
  * @Given /^([^"]+) belongs to ("[^"]+" tax category)$/
  */
 public function productBelongsToTaxCategory(ProductInterface $product, TaxCategoryInterface $taxCategory)
 {
     $product->getMasterVariant()->setTaxCategory($taxCategory);
     $this->objectManager->flush();
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:8,代码来源:ProductContext.php

示例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));
 }
开发者ID:dominikjaglo,项目名称:Sylius,代码行数:12,代码来源:ProductContext.php

示例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);
 }
开发者ID:vikey89,项目名称:Sylius,代码行数:22,代码来源:LoadProductsData.php

示例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();
 }
开发者ID:starspire,项目名称:eventmanager,代码行数:15,代码来源:OrderContext.php

示例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([]);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:8,代码来源:OrderContext.php

示例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();
 }
开发者ID:rpg600,项目名称:Sylius,代码行数:10,代码来源:OrderContext.php

示例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]);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:6,代码来源:OrderContextSpec.php


注:本文中的Sylius\Component\Core\Model\ProductInterface::getMasterVariant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。