/** * Get fields for products * * @param array $productIds * * @return array */ public function getFieldsList($productIds) { $this->prepareAvailableAttributeIds($productIds); $attributeRepo = $this->productManager->getAttributeRepository(); $attributesList = $attributeRepo->findBy(array('id' => $this->getAttributeIds())); $fieldsList = $this->prepareFieldsList($attributesList); return $fieldsList; }
/** * Get attributes configuration for attribute that can be used in grid (as column or filter) * * @return array */ protected function getAttributesConfig() { $attributeIds = $this->getAttributeIds(); if (empty($attributeIds)) { return []; } $currentLocale = $this->getCurrentLocaleCode(); $repository = $this->productManager->getAttributeRepository(); $configuration = $repository->getAttributesAsArray(true, $currentLocale, $attributeIds); return $configuration; }
function let(ProductManager $productManager, UserContext $userContext, CurrencyManager $currencyManager, Locale $en, Locale $de, AttributeRepository $attributeRepository, AbstractProductValue $productValue, CatalogContext $catalogContext, ProductBuilder $productBuilder, ProductMassActionManager $massActionManager, MetricFactory $metricFactory) { $en->getCode()->willReturn('en_US'); $de->getCode()->willReturn('de_DE'); $userContext->getCurrentLocale()->willReturn($en); $userContext->getUserLocales()->willReturn([$en, $de]); $catalogContext->setLocaleCode(Argument::any())->willReturn($catalogContext); $productManager->createProductValue()->willReturn($productValue); $productValue->setAttribute(Argument::any())->willReturn($productValue); $productValue->setLocale(Argument::any())->willReturn($productValue); $productValue->setScope(Argument::any())->willReturn($productValue); $productValue->addPrice(Argument::any())->willReturn($productValue); $productManager->getAttributeRepository()->willReturn($attributeRepository); $this->beConstructedWith($productManager, $userContext, $currencyManager, $catalogContext, $productBuilder, $massActionManager, $metricFactory, ['product_price' => 'Pim\\Bundle\\CatalogBundle\\Model\\ProductPrice', 'product_media' => 'Pim\\Bundle\\CatalogBundle\\Model\\ProductMedia']); }
/** * @param string $code * * @return AbstractAttribute */ public function getAttribute($code) { $attributeRepo = $this->productManager->getAttributeRepository(); $attribute = $attributeRepo->findOneByCode($code); return $attribute; }