コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function apply(DatasourceInterface $datasource, $field, $direction)
 {
     $attribute = $this->attributeRepository->findOneByCode($field);
     $qb = $datasource->getQueryBuilder();
     $pqb = $this->productRepository->getProductQueryBuilder($qb);
     $pqb->addAttributeSorter($attribute, $direction);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function initialize()
 {
     $this->channels = $this->channelRepository->findAll();
     foreach ($this->attributeRepository->getNonIdentifierAttributes() as $attribute) {
         $this->attributes[(string) $attribute->getGroup()][] = $attribute;
         foreach ($this->channels as $channel) {
             $this->addAttributeRequirement($this->factory->createAttributeRequirement($attribute, $channel, false));
         }
     }
 }
コード例 #3
0
 function it_returns_attribute_informations_from_field_name_with_price_attribute($managerRegistry, AttributeRepository $repository, AbstractAttribute $attribute)
 {
     $attribute->getCode()->willReturn('foo');
     $attribute->isLocalizable()->willReturn(false);
     $attribute->isScopable()->willReturn(false);
     $attribute->getBackendType()->willReturn('prices');
     $repository->findByReference('foo')->willReturn($attribute);
     $managerRegistry->getRepository(self::ATTRIBUTE_CLASS)->willReturn($repository);
     $this->extractAttributeFieldNameInfos('foo-USD')->shouldReturn(['attribute' => $attribute, 'locale_code' => null, 'scope_code' => null, 'price_currency' => 'USD']);
 }
コード例 #4
0
 function it_initializes_attribute_requirements_with_all_channels_and_attributes_in_the_PIM(ChannelRepository $channelRepository, Channel $ecommerce, Channel $mobile, AttributeRepository $attributeRepository, AbstractAttribute $name, AbstractAttribute $description, AttributeRequirementFactory $factory, AttributeRequirement $r1, AttributeRequirement $r2, AttributeRequirement $r3, AttributeRequirement $r4)
 {
     $channelRepository->findAll()->willReturn([$ecommerce, $mobile]);
     $attributeRepository->getNonIdentifierAttributes()->willReturn([$name, $description]);
     $factory->createAttributeRequirement($name, $ecommerce, false)->willReturn($r1);
     $r1->getAttributeCode()->willReturn('name');
     $r1->getChannelCode()->willReturn('ecommerce');
     $factory->createAttributeRequirement($name, $mobile, false)->willReturn($r2);
     $r2->getAttributeCode()->willReturn('name');
     $r2->getChannelCode()->willReturn('mobile');
     $factory->createAttributeRequirement($description, $ecommerce, false)->willReturn($r3);
     $r3->getAttributeCode()->willReturn('description');
     $r3->getChannelCode()->willReturn('ecommerce');
     $factory->createAttributeRequirement($description, $mobile, false)->willReturn($r4);
     $r4->getAttributeCode()->willReturn('description');
     $r4->getChannelCode()->willReturn('mobile');
     $this->initialize();
     $this->getAttributeRequirements()->toArray()->shouldReturn(['name_ecommerce' => $r1, 'name_mobile' => $r2, 'description_ecommerce' => $r3, 'description_mobile' => $r4]);
 }
コード例 #5
0
 /**
  * Find common attributes
  * Common attributes are:
  *   - not unique (and not identifier)
  *   - without value AND link to family
  *   - with value
  *
  * @param array $productIds
  *
  * @return \Pim\Bundle\CatalogBundle\Model\AbstractAttribute[]
  */
 public function findCommonAttributes(array $productIds)
 {
     $attributeIds = $this->massActionRepository->findCommonAttributeIds($productIds);
     return $this->attributeRepository->findWithGroups(array_unique($attributeIds), array('conditions' => ['unique' => 0]));
 }
コード例 #6
0
 /**
  * Get the identifier attribute code.
  *
  * @return string
  */
 protected function getIdentifierAttributeCode()
 {
     return $this->attributeRepository->getIdentifierCode();
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function getReferenceProperties()
 {
     return array($this->attributeRepository->getIdentifierCode());
 }
コード例 #8
0
 /**
  * Returns the Attribute
  *
  * @param string $code
  *
  * @return AbstractAttribute
  */
 protected function getAttributeByCode($code)
 {
     return $this->attributeRepository->findOneByCode($code);
 }
コード例 #9
0
 function it_provides_the_identifier_attribute(AttributeRepository $attributeRepository, AbstractAttribute $sku)
 {
     $attributeRepository->findOneBy(['attributeType' => 'pim_catalog_identifier'])->willReturn($sku);
     $this->getIdentifierAttribute()->shouldReturn($sku);
 }
コード例 #10
0
 /**
  * Return the identifier attribute
  *
  * @return AbstractAttribute|null
  */
 public function getIdentifierAttribute()
 {
     return $this->attributeRepository->findOneBy(['attributeType' => 'pim_catalog_identifier']);
 }