本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\ProductValueInterface::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductValueInterface::setOption方法的具体用法?PHP ProductValueInterface::setOption怎么用?PHP ProductValueInterface::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\ProductValueInterface
的用法示例。
在下文中一共展示了ProductValueInterface::setOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
function it_copies_simple_select_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValueInterface $fromProductValue, ProductValueInterface $toProductValue, AttributeOptionInterface $attributeOption)
{
$fromLocale = 'fr_FR';
$toLocale = 'fr_FR';
$toScope = 'mobile';
$fromScope = 'mobile';
$fromAttribute->getCode()->willReturn('fromAttributeCode');
$toAttribute->getCode()->willReturn('toAttributeCode');
$attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled();
$attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled();
$fromProductValue->getData()->willReturn($attributeOption);
$toProductValue->setOption($attributeOption)->shouldBeCalledTimes(3);
$product1->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
$product1->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
$product2->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn(null);
$product2->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
$product3->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
$product3->getValue('toAttributeCode', $toLocale, $toScope)->willReturn(null);
$product4->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
$product4->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
$builder->addProductValue($product3, $toAttribute, $toLocale, $toScope)->shouldBeCalledTimes(1)->willReturn($toProductValue);
$products = [$product1, $product2, $product3, $product4];
foreach ($products as $product) {
$this->copyAttributeData($product, $product, $fromAttribute, $toAttribute, ['from_locale' => $fromLocale, 'to_locale' => $toLocale, 'from_scope' => $fromScope, 'to_scope' => $toScope]);
}
}
示例2:
function it_sets_simpleselect_option_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->findOneBy(['code' => 'attributeOptionCode', 'attribute' => $attribute])->shouldBeCalledTimes(1)->willReturn($attributeOption);
$productValue->setOption($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->setValue([$product1, $product2, $product3], $attribute, 'attributeOptionCode', $locale, $scope);
}
示例3:
function it_sets_attribute_data_simpleselect_option_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('red');
$attrOptionRepository->findOneByIdentifier('attributeCode.red')->shouldBeCalledTimes(3)->willReturn($attributeOption);
$productValue->setOption($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->setAttributeData($product1, $attribute, 'red', ['locale' => $locale, 'scope' => $scope]);
$this->setAttributeData($product2, $attribute, 'red', ['locale' => $locale, 'scope' => $scope]);
$this->setAttributeData($product3, $attribute, 'red', ['locale' => $locale, 'scope' => $scope]);
}