本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\ProductValueInterface::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductValueInterface::getData方法的具体用法?PHP ProductValueInterface::getData怎么用?PHP ProductValueInterface::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\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());
}
示例2: prepareValueFormData
/**
* {@inheritdoc}
*/
public function prepareValueFormData(ProductValueInterface $value)
{
if ($value->getData() && $value->getData()->isEmpty()) {
return $value->getAttribute()->getDefaultValue();
}
$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));
}
示例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(AbstractAttributeType::BACKEND_TYPE_OPTIONS);
$this->beConstructedWith(AbstractAttributeType::BACKEND_TYPE_OPTIONS, 'pim_ajax_entity', $guesser);
}
示例4:
function it_converts_metric_values_given_the_configured_base_unit_in_the_channel($converter, ProductValueInterface $weightValue, ProductValueInterface $surfaceValue, ProductValueInterface $nameValue, AttributeInterface $weight, AttributeInterface $surface, AttributeInterface $name, MetricInterface $weightMetric, MetricInterface $surfaceMetric, ProductInterface $product, ChannelInterface $channel)
{
$weightValue->getAttribute()->willReturn($weight);
$weightValue->getData()->willReturn($weightMetric);
$weight->getCode()->willReturn('weight');
$weightMetric->getFamily()->willReturn('Weight');
$weightMetric->getUnit()->willReturn('KILOGRAM');
$weightMetric->getData()->willReturn(1);
$surfaceValue->getAttribute()->willReturn($surface);
$surfaceValue->getData()->willReturn($surfaceMetric);
$surface->getCode()->willReturn('surface');
$surfaceMetric->getFamily()->willReturn('Surface');
$surfaceMetric->getUnit()->willReturn('METER_SQUARE');
$surfaceMetric->getData()->willReturn(10);
$nameValue->getAttribute()->willReturn($name);
$nameValue->getData()->willReturn('foobar');
$product->getValues()->willReturn(array($weightValue, $surfaceValue, $nameValue));
$channel->getConversionUnits()->willReturn(array('weight' => 'GRAM'));
$converter->setFamily('Weight')->shouldBeCalled();
$converter->convert('KILOGRAM', 'GRAM', 1)->willReturn(0.001);
$converter->setFamily('Surface')->shouldNotBeCalled();
$weightMetric->setData(0.001)->shouldBeCalled();
$weightMetric->setUnit('GRAM')->shouldBeCalled();
$this->convert($product, $channel);
}
示例5: 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]);
}
}
示例6:
function it_adds_violation_with_non_unique_value(ProductManager $productManager, ProductValueInterface $value, ExecutionContextInterface $context, UniqueValue $constraint)
{
$value->getData()->willReturn('a content');
$productManager->valueExists($value)->willReturn(true);
$context->addViolation($constraint->message)->shouldBeCalled();
$this->validate("my_value", $constraint)->shouldReturn(null);
}
示例7: 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;
}
示例8: 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);
}
示例9:
function it_normalizes_product_value_which_is_not_a_number($productValueNormalizer, $localizer, ProductValueInterface $productValue, AttributeInterface $attribute)
{
$options = ['decimal_separator' => ','];
$productValue->getData()->willReturn('shoes');
$attribute->getAttributeType()->willReturn(AttributeTypes::TEXT);
$productValue->getAttribute()->willReturn($attribute);
$productValueNormalizer->normalize($productValue, null, $options)->willReturn(['simple-select' => 'shoes']);
$localizer->convertDefaultToLocalized('', $options)->shouldNotBeCalled();
$this->normalize($productValue, null, $options)->shouldReturn(['simple-select' => 'shoes']);
}
示例10:
function it_normalizes_value_with_decimal_support_backend(ProductValueInterface $value, AbstractAttribute $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]);
}
示例11: 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);
}
示例12: FileNotFoundException
function it_throws_an_exception_if_something_goes_wrong_with_media_normalization($serializer, ProductInterface $product, ProductMediaInterface $media, ProductValueInterface $value, ProductValueInterface $value2, AttributeInterface $attribute)
{
$product->getValues()->willReturn([$value]);
$product->getIdentifier()->willReturn($value2);
$value->getAttribute()->willReturn($attribute);
$value->getData()->willReturn($media);
$value2->getData()->willReturn(23);
$attribute->getAttributeType()->willReturn('pim_catalog_image');
$serializer->normalize([$media], Argument::cetera())->willThrow(new FileNotFoundException('upload/path/img.jpg'));
$this->shouldThrow(new InvalidItemException('The file "upload/path/img.jpg" does not exist', ['item' => 23, 'uploadDirectory' => 'upload/path/']))->duringProcess($product);
}
示例13:
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']);
}
示例14: 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;
}
示例15:
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);
}