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


PHP ProductValueInterface::addOption方法代码示例

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


在下文中一共展示了ProductValueInterface::addOption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 function it_sets_multiselect_value_to_a_product_value($builder, $attrOptionRepository, AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductValueInterface $productValue, AttributeOptionInterface $attributeOption, AttributeOptionInterface $oldOption)
 {
     $locale = 'fr_FR';
     $scope = 'mobile';
     $attribute->getCode()->willReturn('attributeCode');
     $attributeOption->getCode()->willReturn('attributeOptionCode');
     $attrOptionRepository->findOneBy(['code' => 'attributeOptionCode', 'attribute' => $attribute])->shouldBeCalledTimes(1)->willReturn($attributeOption);
     $productValue->getOptions()->willReturn([$oldOption]);
     $productValue->removeOption($oldOption)->shouldBeCalled();
     $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->setValue([$product1, $product2, $product3], $attribute, ['attributeOptionCode'], $locale, $scope);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:16,代码来源:MultiSelectValueSetterSpec.php

示例2:

 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->findOneBy(['code' => 'attributeOptionCode', 'attribute' => $attribute])->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]);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:16,代码来源:MultiSelectAttributeAdderSpec.php

示例3: copyOptions

 /**
  * 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);
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:12,代码来源:MultiSelectAttributeCopier.php

示例4: setProductOption

 /**
  * @param ProductValueInterface $productValue
  * @param ProductValueInterface $value
  */
 protected function setProductOption(ProductValueInterface $productValue, ProductValueInterface $value)
 {
     foreach ($productValue->getOptions() as $option) {
         if (!$value->getOptions()->contains($option)) {
             $productValue->removeOption($option);
         }
     }
     // TODO: Clean this code removing flush for ORM
     if (!class_exists(PimCatalogBundle::DOCTRINE_MONGODB)) {
         $this->productManager->getObjectManager()->flush();
     }
     foreach ($value->getOptions() as $option) {
         $productValue->addOption($option);
     }
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:19,代码来源:EditCommonAttributes.php


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