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


PHP ProductValueInterface::getData方法代码示例

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


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

示例1: prepareValueFormData

 /**
  * {@inheritdoc}
  */
 public function prepareValueFormData(ProductValueInterface $value)
 {
     if (!is_null($value->getData())) {
         return $value->getData();
     }
     return $this->metricFactory->createMetric($value->getAttribute()->getMetricFamily());
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:10,代码来源:MetricType.php

示例2: 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

示例3: let

 function let(AttributeConstraintGuesser $guesser, ProductValueInterface $value, AttributeInterface $color, AttributeOptionInterface $red)
 {
     $value->getAttribute()->willReturn($color);
     $value->getData()->willReturn(new ArrayCollection([$red]));
     $color->getBackendType()->willReturn(AttributeTypes::BACKEND_TYPE_OPTIONS);
     $this->beConstructedWith(AttributeTypes::BACKEND_TYPE_OPTIONS, 'pim_ajax_entity', $guesser);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:7,代码来源:OptionMultiSelectTypeSpec.php

示例4: supportsValue

 /**
  * {@inheritdoc}
  */
 public function supportsValue(ProductValueInterface $productValue)
 {
     $data = $productValue->getData();
     if (null === $data || '' === $data || [] === $data || $data instanceof \Countable && 0 === count($data)) {
         return true;
     }
     return false;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:11,代码来源:EmptyChecker.php

示例5: it_succesfully_checks_complete_attribute

 public function it_succesfully_checks_complete_attribute(ProductValueInterface $value, ChannelInterface $channel, LocaleInterface $locale, ProductValueCompleteCheckerInterface $completenessChecker, AttributeInterface $attribute)
 {
     $value->getAttribute()->willReturn($attribute);
     $value->getData()->willReturn('foo');
     $this->addProductValueChecker($completenessChecker);
     $completenessChecker->supportsValue($value)->willReturn(true);
     $completenessChecker->isComplete($value, $channel, $locale)->willReturn(true);
     $this->isComplete($value, $channel, $locale)->shouldReturn(true);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:9,代码来源:ChainedProductValueCompleteCheckerSpec.php

示例6:

 function it_normalizes_value_with_decimal_support_backend(ProductValueInterface $value, AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('code');
     $attribute->getBackendType()->willReturn('decimal');
     $attribute->isLocalizable()->willReturn(false);
     $attribute->isScopable()->willReturn(false);
     $value->getData()->willReturn('42.42');
     $value->getAttribute()->willReturn($attribute);
     $this->normalize($value, 'mongodb_json', [])->shouldReturn(['code' => 42.42]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:10,代码来源:ProductValueNormalizerSpec.php

示例7: it_succesfully_checks_incomplete_price_collection

 public function it_succesfully_checks_incomplete_price_collection(ProductValueInterface $value, ChannelInterface $channel, LocaleInterface $locale, ArrayCollection $arrayCollection, CurrencyInterface $currency1, CurrencyInterface $currency2, ProductPriceInterface $price1)
 {
     $channel->getCurrencies()->willReturn($arrayCollection);
     $arrayCollection->toArray()->willReturn([$currency1, $currency2]);
     $currency1->getCode()->willReturn('USD');
     $price1->getCurrency()->willReturn('USD');
     $price1->getData()->willReturn(null);
     $value->getData()->willReturn([$price1]);
     $this->isComplete($value, $channel, $locale)->shouldReturn(false);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:10,代码来源:PriceCompleteCheckerSpec.php

示例8:

 function it_normalizes_date($serializer, ProductValueInterface $productValue, AttributeInterface $attribute)
 {
     $productValue->getData()->willReturn('2000-10-28');
     $productValue->getScope()->willReturn(null);
     $productValue->getLocale()->willReturn(null);
     $attribute->getAttributeType()->willReturn(AttributeTypes::DATE);
     $attribute->isDecimalsAllowed()->willReturn(false);
     $productValue->getAttribute()->willReturn($attribute);
     $serializer->normalize('2000-10-28', 'json', ['decimals_allowed' => false])->willReturn('2000-10-28');
     $this->normalize($productValue, 'json', ['decimals_allowed' => false])->shouldReturn(['locale' => null, 'scope' => null, 'data' => '2000-10-28']);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:ProductValueNormalizerSpec.php

示例9: prepareValueFormData

 /**
  * {@inheritdoc}
  */
 public function prepareValueFormData(ProductValueInterface $value)
 {
     $iterator = $value->getData()->getIterator();
     if (true === $value->getAttribute()->getProperty('autoOptionSorting')) {
         $iterator->uasort('strcasecmp');
     } else {
         $iterator->uasort(function ($first, $second) {
             return $first->getSortOrder() < $second->getSortOrder() ? -1 : 1;
         });
     }
     return new ArrayCollection(iterator_to_array($iterator));
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:15,代码来源:OptionMultiSelectType.php

示例10:

 function it_normalizes_a_product_value_into_mongodb_document($mongoFactory, $serializer, ProductValueInterface $value, AttributeInterface $attribute, \MongoDBRef $mongoDBRef, \MongoId $mongoId)
 {
     $context = ['_id' => $mongoId, 'collection_name' => 'product'];
     $mongoFactory->createMongoId()->willReturn($mongoId);
     $mongoFactory->createMongoDBRef('product', $mongoId)->willReturn($mongoDBRef);
     $attribute->getId()->willReturn(123);
     $attribute->getBackendType()->willReturn('text');
     $value->getAttribute()->willReturn($attribute);
     $value->getData()->willReturn('my description');
     $value->getLocale()->willReturn(null);
     $value->getScope()->willReturn(null);
     $this->normalize($value, 'mongodb_document', $context)->shouldReturn(['_id' => $mongoId, 'attribute' => 123, 'entity' => $mongoDBRef, 'text' => 'my description']);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:ProductValueNormalizerSpec.php

示例11: isComplete

 /**
  * {@inheritdoc}
  */
 public function isComplete(ProductValueInterface $productValue, ChannelInterface $channel = null, LocaleInterface $locale = null)
 {
     $expectedCurrencies = array_map(function ($currency) {
         return $currency->getCode();
     }, $channel->getCurrencies()->toArray());
     foreach ($expectedCurrencies as $currency) {
         foreach ($productValue->getData() as $price) {
             if ($price->getCurrency() === $currency && null === $price->getData()) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:17,代码来源:PriceCompleteChecker.php

示例12:

 function it_does_not_convert_null_metric_values_in_the_channel($converter, ProductValueInterface $weightValue, AttributeInterface $weight, MetricInterface $weightMetric, ProductInterface $product, ChannelInterface $channel)
 {
     $weightValue->getAttribute()->willReturn($weight);
     $weightValue->getData()->willReturn($weightMetric);
     $weight->getCode()->willReturn('weight');
     $weightMetric->getFamily()->willReturn('Weight');
     $weightMetric->getUnit()->willReturn(null);
     $weightMetric->getData()->willReturn(null);
     $product->getValues()->willReturn(array($weightValue));
     $channel->getConversionUnits()->willReturn(array('weight' => 'GRAM'));
     $converter->setFamily('Weight')->shouldNotBeCalled();
     $converter->convert('KILOGRAM', 'GRAM', 1)->shouldNotBeCalled();
     $weightMetric->setData(null)->shouldNotBeCalled();
     $weightMetric->setUnit('GRAM')->shouldNotBeCalled();
     $this->convert($product, $channel);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:16,代码来源:MetricConverterSpec.php

示例13: validatePrices

 /**
  * Validate that prices contain the currencies required by the channel
  *
  * @param ProductValueInterface $value
  * @param Constraint            $constraint
  */
 protected function validatePrices(ProductValueInterface $value, Constraint $constraint)
 {
     $channel = $constraint->getChannel();
     $expectedCurrencies = array_map(function ($currency) {
         return $currency->getCode();
     }, $channel->getCurrencies()->toArray());
     foreach ($expectedCurrencies as $currency) {
         foreach ($value->getData() as $price) {
             if ($price->getCurrency() === $currency) {
                 if (null === $price->getData()) {
                     $this->context->buildViolation($constraint->messageComplete)->addViolation();
                 }
             }
         }
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:22,代码来源:ProductValueCompleteValidator.php

示例14:

 function it_does_not_add_value_if_already_present(ProductValueInterface $notPresent, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $present, ProductInterface $anotherProduct)
 {
     $notPresent->getProduct()->willReturn($product);
     $notPresent->getData()->willReturn('new-data');
     $notPresent->getAttribute()->willReturn($attribute);
     $notPresent->getLocale()->willReturn(null);
     $notPresent->getScope()->willReturn(null);
     $attribute->getCode()->willReturn('sku');
     $this->addValue($notPresent)->shouldReturn(true);
     $present->getProduct()->willReturn($anotherProduct);
     $present->getData()->willReturn('new-data');
     $present->getAttribute()->willReturn($attribute);
     $present->getLocale()->willReturn(null);
     $present->getScope()->willReturn(null);
     $attribute->getCode()->willReturn('sku');
     $this->addValue($present)->shouldReturn(false);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:17,代码来源:UniqueValuesSetSpec.php

示例15: getSimpleValue

 /**
  * @param ProductValueInterface $productValue
  * @param null                  $format
  * @param array                 $context
  *
  * @return mixed
  */
 protected function getSimpleValue(ProductValueInterface $productValue, $format = null, array $context = [])
 {
     $attributeType = $productValue->getAttribute()->getAttributeType();
     $context['is_decimals_allowed'] = $productValue->getAttribute()->isDecimalsAllowed();
     // if decimals_allowed is false, we return an integer
     // if true, we return a string to avoid to loose precision (http://floating-point-gui.de)
     if (AttributeTypes::NUMBER === $attributeType && null !== $productValue->getData() && is_numeric($productValue->getData())) {
         return $productValue->getAttribute()->isDecimalsAllowed() ? number_format($productValue->getData(), static::DECIMAL_PRECISION, '.', '') : (int) $productValue->getData();
     }
     if (in_array($attributeType, [AttributeTypes::OPTION_SIMPLE_SELECT, AttributeTypes::REFERENCE_DATA_SIMPLE_SELECT])) {
         return $productValue->getData()->getCode();
     }
     return $this->serializer->normalize($productValue->getData(), $format, $context);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:21,代码来源:ProductValueNormalizer.php


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