/** * @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 = str_replace(' ', '_', strtoupper($name)); } $productAttribute->setCode($code); $productAttribute->setName($name); $this->productAttributeRepository->add($productAttribute); $this->sharedStorage->set('product_attribute', $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); }
/** * {@inheritdoc} */ public function create(array $options = []) { $options = $this->optionsResolver->resolve($options); /** @var ProductOptionInterface $productAttribute */ $productAttribute = $this->productAttributeFactory->createTyped($options['type']); $productAttribute->setCode($options['code']); foreach ($this->getLocales() as $localeCode) { $productAttribute->setCurrentLocale($localeCode); $productAttribute->setFallbackLocale($localeCode); $productAttribute->setName($options['name']); } return $productAttribute; }
/** * @param string $type * @param string $name * @param string $code * * @return AttributeInterface */ private function createProductAttribute($type, $name, $code = 'PA112') { $productAttribute = $this->productAttributeFactory->createTyped($type); $productAttribute->setCode($code); $productAttribute->setName($name); $this->objectManager->persist($productAttribute); return $productAttribute; }