/** * Get the internal key that is used to index * a product value in a collection of values * * @param AbstractProductValue $value * * @return string */ public static function getKey(AbstractProductValue $value) { $attribute = $value->getAttribute(); $key = $attribute->getCode(); if ($attribute->isLocalizable()) { $key .= '_' . $value->getLocale(); } if ($attribute->isScopable()) { $key .= '_' . $value->getScope(); } return $key; }
function it_normalizes_a_product_value_into_mongodb_document($mongoFactory, $serializer, AbstractProductValue $value, AbstractAttribute $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']); }