コード例 #1
0
 function it_adds_attribute_data_on_multiselect_value_to_a_product_value($builder, $attrOptionRepository, AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductValueInterface $productValue, AttributeOptionInterface $attributeOption)
 {
     $locale = 'fr_FR';
     $scope = 'mobile';
     $attribute->getCode()->willReturn('attributeCode');
     $attributeOption->getCode()->willReturn('attributeOptionCode');
     $attrOptionRepository->findOneByIdentifier('attributeCode.attributeOptionCode')->shouldBeCalledTimes(3)->willReturn($attributeOption);
     $productValue->addOption($attributeOption)->shouldBeCalled();
     $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue);
     $product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue);
     $product2->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn(null);
     $product3->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue);
     $this->addAttributeData($product1, $attribute, ['attributeOptionCode'], ['locale' => $locale, 'scope' => $scope]);
     $this->addAttributeData($product2, $attribute, ['attributeOptionCode'], ['locale' => $locale, 'scope' => $scope]);
     $this->addAttributeData($product3, $attribute, ['attributeOptionCode'], ['locale' => $locale, 'scope' => $scope]);
 }
コード例 #2
0
 /**
  * Copy attribute options into a multi select attribute
  *
  * @param ProductValueInterface $fromValue
  * @param ProductValueInterface $toValue
  */
 protected function copyOptions(ProductValueInterface $fromValue, ProductValueInterface $toValue)
 {
     foreach ($fromValue->getOptions() as $attributeOption) {
         $toValue->addOption($attributeOption);
     }
 }