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


PHP ProductInterface::getValue方法代码示例

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


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

示例1: foreach

 function it_copies_multi_select_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValue $fromProductValue, ProductValue $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->getOptions()->willReturn([$attributeOption])->shouldBeCalled(3);
     $toProductValue->getOptions()->willReturn([$attributeOption]);
     $toProductValue->removeOption($attributeOption)->shouldBeCalled();
     $toProductValue->addOption($attributeOption)->shouldBeCalled();
     $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:vpetrovych,项目名称:pim-community-dev,代码行数:28,代码来源:MultiSelectAttributeCopierSpec.php

示例2: foreach

 function it_copies_a_price_collection_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValue $fromProductValue, ProductValue $toProductValue, ProductPriceInterface $price)
 {
     $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([$price]);
     $price->getCurrency()->willReturn('USD');
     $price->getData()->willReturn(123);
     $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);
     $builder->addPriceForCurrencyWithData($toProductValue, 'USD', 123)->shouldBeCalled();
     $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:vpetrovych,项目名称:pim-community-dev,代码行数:28,代码来源:PriceCollectionAttributeCopierSpec.php

示例3: copySingleValue

 /**
  * Copy single value
  *
  * @param ProductInterface   $product
  * @param AttributeInterface $fromAttribute
  * @param AttributeInterface $toAttribute
  * @param string             $fromLocale
  * @param string             $toLocale
  * @param string             $fromScope
  * @param string             $toScope
  */
 protected function copySingleValue(ProductInterface $product, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope)
 {
     $fromValue = $product->getValue($fromAttribute->getCode(), $fromLocale, $fromScope);
     if (null !== $fromValue) {
         $toValue = $product->getValue($toAttribute->getCode(), $toLocale, $toScope);
         if (null === $toValue) {
             $toValue = $this->productBuilder->addProductValue($product, $toAttribute, $toLocale, $toScope);
         }
         $this->copyOptions($fromValue, $toValue);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:22,代码来源:PriceCollectionValueCopier.php

示例4:

 function it_adds_a_violation_when_validates_a_product_with_missing_value_for_an_axe_of_its_variant_group($context, ProductInterface $product, GroupInterface $tShirtVariantGroup, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeValue, ProductValueInterface $identifierValue, HasVariantAxes $constraint, ConstraintViolationBuilderInterface $violation)
 {
     $tShirtVariantGroup->getCode()->willReturn('tshirt');
     $tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
     $sizeAttribute->getCode()->willReturn('size');
     $colorAttribute->getCode()->willReturn('color');
     $product->getIdentifier()->willReturn($identifierValue);
     $product->getVariantGroup()->willReturn($tShirtVariantGroup);
     $product->getValue('size')->willReturn($sizeValue);
     $product->getValue('color')->willReturn(null);
     $sizeValue->getData()->willReturn('XL');
     $context->buildViolation('The product "%product%" is in the variant group "%variant%" but it misses the following axes: %axes%.', ['%product%' => $identifierValue, '%variant%' => 'tshirt', '%axes%' => 'color'])->shouldBeCalled()->willReturn($violation);
     $this->validate($product, $constraint);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:14,代码来源:HasVariantAxesValidatorSpec.php

示例5:

 function it_allows_setting_option_to_null(ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value)
 {
     $attribute->getCode()->willReturn('choice');
     $product->getValue('choice', null, null)->shouldBeCalled()->willReturn($value);
     $value->setOption(null)->shouldBeCalled();
     $this->setValue([$product], $attribute, null);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:7,代码来源:SimpleSelectValueSetterSpec.php

示例6:

 function it_allows_setting_attribute_data_option_to_null(ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value)
 {
     $attribute->getCode()->willReturn('choice');
     $product->getValue('choice', 'fr_FR', 'mobile')->shouldBeCalled()->willReturn($value);
     $value->setOption(null)->shouldBeCalled();
     $this->setAttributeData($product, $attribute, null, ['locale' => 'fr_FR', 'scope' => 'mobile']);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:7,代码来源:SimpleSelectAttributeSetterSpec.php

示例7:

 function it_creates_and_sets_geolocation_to_product_value($productBuilder, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value)
 {
     $attribute->getCode()->shouldBeCalled()->willReturn('geolocation');
     $product->getValue('geolocation', 'FR', 'master')->shouldBeCalled()->willReturn(null);
     $productBuilder->addProductValue($product, $attribute, 'FR', 'master')->shouldBeCalled()->willReturn($value);
     $value->setData(Argument::type('CleverAge\\Bundle\\GeolocAttributeBundle\\Model\\Geolocation'))->shouldBeCalled();
     $this->setValue([$product], $attribute, ['latitude' => 12, 'longitude' => 12], 'FR', 'master');
 }
开发者ID:abdeldayem,项目名称:akeneo-geoloc-attribute,代码行数:8,代码来源:GeolocationSetterSpec.php

示例8: setMedia

 /**
  * Set media in the product value
  *
  * @param ProductInterface       $product
  * @param AttributeInterface     $attribute
  * @param FileInfoInterface|null $fileInfo
  * @param string|null            $locale
  * @param string|null            $scope
  */
 protected function setMedia(ProductInterface $product, AttributeInterface $attribute, FileInfoInterface $fileInfo = null, $locale = null, $scope = null)
 {
     $value = $product->getValue($attribute->getCode(), $locale, $scope);
     if (null === $value) {
         $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope);
     }
     $value->setMedia($fileInfo);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:17,代码来源:MediaAttributeSetter.php

示例9: copySingleValue

 /**
  * @param ProductInterface   $product
  * @param AttributeInterface $fromAttribute
  * @param AttributeInterface $toAttribute
  * @param string             $fromLocale
  * @param string             $toLocale
  * @param string             $fromScope
  * @param string             $toScope
  */
 protected function copySingleValue(ProductInterface $product, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope)
 {
     $fromValue = $product->getValue($fromAttribute->getCode(), $fromLocale, $fromScope);
     if (null !== $fromValue) {
         $fromData = $fromValue->getData();
         $toValue = $product->getValue($toAttribute->getCode(), $toLocale, $toScope);
         if (null === $toValue) {
             $toValue = $this->productBuilder->addProductValue($product, $toAttribute, $toLocale, $toScope);
         }
         if (null === ($metric = $toValue->getMetric())) {
             $metric = $this->metricFactory->createMetric($fromData->getFamily());
         }
         $metric->setUnit($fromData->getUnit());
         $metric->setData($fromData->getData());
         $toValue->setMetric($metric);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:26,代码来源:MetricValueCopier.php

示例10: setOption

 /**
  * Set option into the product value
  *
  * @param ProductInterface              $product
  * @param AttributeInterface            $attribute
  * @param AttributeOptionInterface|null $option
  * @param string|null                   $locale
  * @param string|null                   $scope
  */
 protected function setOption(ProductInterface $product, AttributeInterface $attribute, AttributeOptionInterface $option = null, $locale = null, $scope = null)
 {
     $value = $product->getValue($attribute->getCode(), $locale, $scope);
     if (null === $value) {
         $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope);
     }
     $value->setOption($option);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:17,代码来源:SimpleSelectAttributeSetter.php

示例11: setData

 /**
  * Set data into product value
  *
  * @param ProductInterface   $product
  * @param AttributeInterface $attribute
  * @param mixed              $data
  * @param string             $locale
  * @param string             $scope
  */
 protected function setData(ProductInterface $product, AttributeInterface $attribute, $data, $locale, $scope)
 {
     $value = $product->getValue($attribute->getCode(), $locale, $scope);
     if (null === $value) {
         $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope);
     }
     $value->setData($data);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:17,代码来源:NumberAttributeSetter.php

示例12: getImagePath

 /**
  * Returns the image path for an attribute of a product. If no image is found, returns null.
  *
  * @param ProductInterface   $product
  * @param AttributeInterface $attribute
  * @param string             $locale
  * @param string             $scope
  *
  * @return string|null
  */
 public function getImagePath(ProductInterface $product, AttributeInterface $attribute, $locale, $scope)
 {
     $productValue = $product->getValue($attribute->getCode(), $locale, $scope);
     $path = null;
     if (null !== $productValue->getMedia() && null !== $productValue->getMedia()->getKey()) {
         $path = sprintf('media/cache/thumbnail/%s', $productValue->getMedia()->getKey());
     }
     return $path;
 }
开发者ID:SamirBoulil,项目名称:pim-community-dev,代码行数:19,代码来源:ImageExtension.php

示例13: let

 function let(ProductRepositoryInterface $productRepository, UniqueValuesSet $uniqueValuesSet, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value)
 {
     $this->beConstructedWith($productRepository, $uniqueValuesSet);
     $product->getValue('unique_attribute')->willReturn($value);
     $form->getData()->willReturn($product);
     $context->getPropertyPath()->willReturn(self::PROPERTY_PATH);
     $context->getRoot()->willReturn($form);
     $this->initialize($context);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:9,代码来源:UniqueValueValidatorSpec.php

示例14: let

 function let(ProductManager $productManager, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value)
 {
     $this->beConstructedWith($productManager);
     $product->getValue('sku')->willReturn($value);
     $form->getData()->willReturn($product);
     $context->getPropertyPath()->willReturn(self::PROPERTY_PATH);
     $context->getRoot()->willReturn($form);
     $this->initialize($context);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:9,代码来源:UniqueValueValidatorSpec.php

示例15: addOptions

 /**
  * Adds options into the product value
  *
  * @param ProductInterface   $product
  * @param AttributeInterface $attribute
  * @param array              $attributeOptions
  * @param string             $locale
  * @param string             $scope
  */
 protected function addOptions(ProductInterface $product, AttributeInterface $attribute, $attributeOptions, $locale, $scope)
 {
     $value = $product->getValue($attribute->getCode(), $locale, $scope);
     if (null === $value) {
         $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope);
     }
     foreach ($attributeOptions as $attributeOption) {
         $value->addOption($attributeOption);
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:19,代码来源:MultiSelectAttributeAdder.php


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