/** * @Given /^the store allows paying (\w+) for (all channels)$/ */ public function storeAllowsPayingForAllChannels($paymentMethodName, array $channels) { $paymentMethod = $this->createPaymentMethod($paymentMethodName, StringInflector::nameToUppercaseCode($paymentMethodName), 'Payment method', false); foreach ($channels as $channel) { $paymentMethod->addChannel($channel); } }
/** * @param string $type * @param string $name * @param string|null $code * * @return ProductAttributeInterface */ private function createProductAttribute($type, $name, $code = null) { $productAttribute = $this->productAttributeFactory->createTyped($type); if (null === $code) { $code = StringInflector::nameToUppercaseCode($name); } $productAttribute->setCode($code); $productAttribute->setName($name); return $productAttribute; }
/** * @param string $type * @param string $name * @param string|null $code */ private function createProductAttribute($type, $name, $code = null) { $productAttribute = $this->productAttributeFactory->createTyped($type); if (null === $code) { $code = StringInflector::nameToUppercaseCode($name); } $productAttribute->setCode($code); $productAttribute->setName($name); $this->productAttributeRepository->add($productAttribute); $this->sharedStorage->set('product_attribute', $productAttribute); }
/** * @param string $productName * @param int $price * @param string|null $date * @param ChannelInterface|null $channel * * @return ProductInterface */ private function createProduct($productName, $price = 100, $date = null, ChannelInterface $channel = null) { /** @var ProductInterface $product */ $product = $this->productFactory->createWithVariant(); $product->setName($productName); $product->setCode(StringInflector::nameToUppercaseCode($productName)); $product->setSlug($this->slugGenerator->generate($productName)); $product->setCreatedAt(new \DateTime($date)); /** @var ProductVariantInterface $productVariant */ $productVariant = $this->defaultVariantResolver->getVariant($product); if (null === $channel && $this->sharedStorage->has('channel')) { $channel = $this->sharedStorage->get('channel'); } if (null !== $channel) { $productVariant->addChannelPricing($this->createChannelPricingForChannel($price, $channel)); } $productVariant->setCode($product->getCode()); return $product; }
/** * @param string $productName * * @return string */ private function convertToCode($productName) { return StringInflector::nameToUppercaseCode($productName); }
/** * @param string $productName * @param int $price * * @return ProductInterface */ private function createProduct($productName, $price = 0, $date = null) { /** @var ProductInterface $product */ $product = $this->productFactory->createWithVariant(); $product->setName($productName); $product->setCode(StringInflector::nameToUppercaseCode($productName)); $product->setSlug($this->slugGenerator->generate($productName)); $product->setCreatedAt(new \DateTime($date)); /** @var ProductVariantInterface $productVariant */ $productVariant = $this->defaultVariantResolver->getVariant($product); $productVariant->setPrice($price); $productVariant->setCode($product->getCode()); return $product; }