Class ProductJsonSerializer
This class will serialize and deserialize a Product entity. It can be used into many places where PHP interacts with external requests such as AJAX or API communication.
| category |
System |
|---|---|
| package |
Extensions |
| subpackage |
Serializers |
__construct()
If you override this constructor do not forget to call it from the child class.
_deserializeAddonValues( $json) : array
Common method for deserializing addon values in various resource serializer classes.
array
_deserializeImages( $json) : \ProductImageContainer
| Throws |
|
|---|
\ProductImageContainer
_deserializeLanguageSpecificProperty(mixed $object, \stdobject $json, string $property, $type = 'StringType')
This method will deserialize the value of a JSON property and set the value to the object by using the corresponding setter method.
| Throws |
|
|---|
mixedThe object being deserialized.
\stdobjectThe JSON object containing the property value.
stringThe property name to be deserialized.
_deserializeSettings(\ProductSettingsInterface $settings, $json) : \ProductSettingsInterface
_serializeAddonValues(\KeyValueCollection $addonValues) : array
Common method for serializing addon values in various resource serializer classes.
\KeyValueCollection
array
_serializeImages(\ProductImageContainerInterface $imageContainer) : array
_serializeLanguageSpecificProperty(mixed $object, string $property) : array
In order for this method to work there has to be a proper getter method in the object instance. Otherwise a RuntimeException will be thrown.
| Throws |
|
|---|
mixedThe object instance containing the property.
stringThe property name to be serialized.
array
_serializeSettings(\ProductSettingsInterface $settings) : array
decodeJson(mixed $string) : array
mixedThe (potential) JSON string
arrayThe decoded JSON array
deserialize( $string, $baseObject = null)
jsonEncode(array $data) : string
This function provides PHP v5.3 compatibility and it should be used when serialized objects need to be encoded directly from the serializer instance.
arrayContains the data to be JSON encoded.
stringReturns the encoded JSON string that represents the data.
serialize( $object, $encode = true)
serializeProductArray(array $storedProducts, boolean $encode = true) : array|string
arrayThe array of ProductInterfaces
booleanIndicates if the result should be returned JSON encoded.
array|stringEither a JSON string or the serialized array (depends on the $encode parameter)
languageProvider : \LanguageProviderInterface