当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductValueInterface::setOption方法代码示例

本文整理汇总了PHP中Pim\Component\Catalog\Model\ProductValueInterface::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductValueInterface::setOption方法的具体用法?PHP ProductValueInterface::setOption怎么用?PHP ProductValueInterface::setOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Component\Catalog\Model\ProductValueInterface的用法示例。


在下文中一共展示了ProductValueInterface::setOption方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:26,代码来源:SimpleSelectAttributeCopierSpec.php

示例2:

 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]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:16,代码来源:SimpleSelectAttributeSetterSpec.php


注:本文中的Pim\Component\Catalog\Model\ProductValueInterface::setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。