commercetools/php-sdk
Deprecated PHP SDK for commercetools Composable Commerce. Provides native PHP models/helpers, IDE autocompletion, object mapping, i18n, and an OAuth2 client with caching and async/concurrent request support. Requires PHP 5.6+ (Guzzle).
key functionality (57e803c), closes #330PHP minimum version is now 5.6
guzzle/log-subscriber has been removed as a dependency
AssetDraft: AssetDraft requires CustomFieldObjectDraft instead of CustomFieldObject
Before:
$assetDraft = AssetDraft::of()->setCustom(CustomFieldObject::of());
After:
$assetDraft = AssetDraft::of()->setCustom(CustomFieldObjectDraft::of());
OAuth: Manager::getCacheAdapter() method scope has been changed from public to protected
ProductSearch: markMatchingVariants has been disabled by default
For performance reasons the markMatchingVariants flag has been disabled by default. In order to use markMatchingVariants feature please enable it explicit.
Before:
$request = ProductProjectionSearchRequest::of();
After:
$request = ProductProjectionSearchRequest::of()->markMatchingVariants(true);
Token caching is now using PSR-6 or PSR-16 cache adapters only. Removed classes:
Use an appropiate PSR-6 or PRS-16 cache adapter as a replacement. The SDK uses the cache\apcu-adapter as default or if available the cache\filesystem-adapter
Deprecations have been removed
Context doesn't extend Pimple\Container anymore
Pimple has been removed as a dependency
The class Commercetools\Commons\Helper\PriceFinder has been deprecated. Please use the
price selection functionality of Composable Commerce. E.g. ProductProjectionSearchRequest::of()->currency('EUR')->country('DE')
AssetDraft: AssetDraft requires CustomFieldObjectDraft instead of CustomFieldObject
Before:
$assetDraft = AssetDraft::of()->setCustom(CustomFieldObject::of());
After:
$assetDraft = AssetDraft::of()->setCustom(CustomFieldObjectDraft::of());
OAuth: Manager::getCacheAdapter() method scope has been changed from public to protected
ProductSearch: markMatchingVariants has been disabled by default
For performance reasons the markMatchingVariants flag has been disabled by default. In order to use markMatchingVariants feature please enable it explicit.
Before:
$request = ProductProjectionSearchRequest::of();
After:
$request = ProductProjectionSearchRequest::of()->markMatchingVariants(true);
PHP minimum version is now 5.6
Token caching is now using PSR-6 or PSR-16 cache adapters only. Removed classes:
Use an appropiate PSR-6 or PRS-16 cache adapter as a replacement. The SDK uses the cache\apcu-adapter as default or if available the cache\filesystem-adapter
Deprecations have been removed
Context doesn't extend Pimple\Container anymore
Pimple has been removed as a dependency
There had been no changes
Product: renamed the ProductSetSKUAction to ProductSetSKUNotStageableAction
Before:
ProductSetSKUAction::ofVariantId()
After:
ProductSetSKUNotStageableAction::ofVariantId() // old behavior action
ProductSetSkuAction::ofVariantId() // stageable action
Product: fix type of price collections
Before:
ProductAddVariantAction::of()->setPrices(PriceCollection::of()->add(Price::of()))
After:
ProductAddVariantAction::of()->setPrices(PriceDraftCollection::of()->add(PriceDraft::of()))
Customer: adjust customer email verification request to API changes
Before:
CustomerEmailConfirmRequest::ofIdVersionAndToken($id, $version, $token)
After:
CustomerEmailConfirmRequest::ofToken($token)
Customer: adjust customer password change request to API changes
Before:
CustomerPasswordResetRequest::ofIdVersionTokenAndPassword($id, $version, $token, $newPassword)
After:
CustomerPasswordResetRequest::ofTokenAndPassword($token, $newPassword)
Facet, Filter, FilterRange and FilterRangeCollection in namespace Commercetools\Core\Model\Product have been marked as deprecated and will be removed in v1.0.0. Please use the classes found in namespace Commercetools\Core\Model\Product\Search instead.
Changed named constructors for type update actions
Before:
TypeAddLocalizedEnumValueAction::ofEnum(...)
TypeAddEnumValueAction::ofEnum(...)
TypeChangeEnumValueOrderAction::ofEnums(...)
TypeChangeLocalizedEnumValueOrderAction::ofEnums(...)
TypeChangeLabelAction::ofLabel(...)
After:
TypeAddLocalizedEnumValueAction::ofNameAndEnum(...)
TypeAddEnumValueAction::ofNameAndEnum(...)
TypeChangeEnumValueOrderAction::ofNameAndEnums(...)
TypeChangeLocalizedEnumValueOrderAction::ofNameAndEnums(...)
TypeChangeLabelAction::ofNameAndLabel(...)
CustomObject: CustomObjectCreateRequest expects CustomObjectDraft object
Before:
$request = CustomObjectCreateRequest::ofObject(CustomObject::of()->setContainer('test')->setKey('test-key')->setValue(json_encode($value)));
After:
$request = CustomObjectCreateRequest::ofObject(CustomObjectDraft::ofContainerKeyAndValue('test', 'test-key', $value));
CustomFields: the type reference had been changed at the API
Before:
$customFieldObjectDraft->setTypeId('type-12345');
$customFieldObjectDraft->setTypeKey('type-key');
After:
$customFieldObjectDraft->setType(TypeReference::ofId('type-12345'));
$customFieldObjectDraft->setType(TypeReference::ofKey('type-key'));
added PriceDraft to price update actions
The new PriceDraft object has been added as type hint to ProductAddPriceAction and ProductChangePriceAction. The ProductVariantDraft expects now a PriceDraftCollection
discountedPrice at LineItems has been removed
The discountedPrice field has been deprecated at the API and therefor was removed from the SDK.
Before:
$lineItem->getDiscountedPrice();
$discountedCentAmount = $lineItem->getDiscountedPrice()->getValue()->getCentAmount();
After:
$lineItem->getDiscountedPricePerQuantity();
$discountedCentAmount = 0;
foreach ($lineItem->getDiscountedPricePerQuantity() as $discountedPricePerQuantity) {
$discountedCentAmount += $discountedPricePerQuantity()->getQuantity() *
$discountedPricePerQuantity->getDiscountedPrice()->getValue()->getCentAmount();
}
(b0bf1b7)
comments endpoint has been removed from the API
All models and request objects have been removed from the SDK
<a name"1.0.0-RC2">
SphereException and SphereServiceException have been renamed to ApiException and ApiServiceException
Before
try {
...
} catch(SphereException $e) {
}
After:
try {
...
} catch(ApiException $e) {
}
(813a6cb7)
Namespace Sphere has been renamed to Commercetools
Namespace and Use statements and fully qualified class names have to be adjusted. E.g.
Before
use Sphere\Core\Client;
$class = '\Sphere\Core\Client';
After:
use Commercetools\Core\Client;
$class = '\Commercetools\Core\Client';
(4bc9575f)
<a name"1.0.0-RC1">
QueryRequests renamed to singular form
To streamline the naming schemes between the SDKs QueryRequests have been renamed to their singular form. E.g.:
Before:
$request = CategoriesQueryRequest::of();
After:
$request = CategoryQueryRequest::of();
(8de23283)
SingleResourceResponse renamed to ResourceResponse
To streamline the naming schemes between the SDKs SingleResourceResponse has been renamed to ResourceResponse
(4199c815)
ImportLineItem renamed to LineItemImportDraft
To streamline the naming schemes between the SDKs ImportProductVariant, ImportLineItem and ImportLineItemCollection have been renamed to ProductVariantImportDraft, LineItemImportDraft and LineItemImportDraftCollection.
(018c7493)
CartDiscountCodeReference renamed to DiscountCodeInfo
To streamline the naming schemes between the SDKs CartDiscountCodeReference has been renamed to DiscountCodeInfo
(db14db07)
DeleteById requests renamed to Delete requests
To streamline the naming schemes between the SDKs delete requests have been renamed. E.g.:
Before:
$request = ProductDeleteByIdRequest::ofIdAndVersion('<id>', <version>);
After:
$request = ProductDeleteRequest::ofIdAndVersion('<id>', <version>);
(896e95a9)
FetchBy requests renamed to ByGetRequest
To streamline the naming schemes between the SDKs FetchBy requests have been renamed to ByGet requests. E.g.:
Before:
$request = ProductFetchByIdRequest::ofId('<id>');
After:
$request = ProductByIdGetRequest::ofId('<id>');
(d601dcfc)
Document has been renamed to Resource
To streamline the naming schemes between the SDKs Document has been renamed to Resource. Type checks have to be adjusted
Before:
if ($object instanceof \Sphere\Core\Model\Common\Document)
After:
if ($object instanceof \Sphere\Core\Model\Common\Resource)
(5704fa3e)
ProductSearchEndpoint has been renamed
Before:
$endpoint = ProductSearchEndpoint::endpoint();
After:
$endpoint = ProductProjectionEndpoint::endpoint();
closes #103
(e1b6989f)
ProductsSearchRequest has been renamed
Before:
$request = ProductsSearchRequest::of();
After:
$request = ProductProjectionSearchRequest::of();
closes #103
(bd1bf7b1)
config object fromArray method is declared static
Before:
config = new Config();
config->fromArray($configArray);
After:
config = Config::fromArray($configArray);
closes #101
(1a0c350f)
ext-intl is now mandatory
(2afea8ad)
getters return null if value is not set
To have a more reliable return values the implied instantiation of empty objects has been removed. This means before using a value is must be set explicit. Example for collections
Before:
$obj = ProductTypeDraft::ofNameAndDescription('test', 'test');
$obj->getAttributes()->add(AttributeDefinition::of()->setName('test'));
After:
$obj = ProductTypeDraft::ofNameAndDescription('test', 'test');
$obj->setAttributes(AttributeDefinitionCollection::of()->add(AttributeDefinition::of()->setName('test')));
Closes #113
(8b138e7b)
all http client exceptions are now wrapped inside the SphereException hierarchy
Before:
try {
$response = $client->execute($request)
} catch(\GuzzleHttp\Exception\RequestException $e) {
...
}
After:
try {
$response = $client->execute($request)
} catch(\Sphere\Core\Error\SphereException $e) {
...
}
(a169611b)
rename client method future to executeAsync
To streamline the request executing methods the future method has been renamed. To migrate the code follow the example:
Before:
$response = $client->future($request);
After:
$response = $client->executeAsync($request);
(51da11fa)
changes the static "of" constructor to named constructors
The static constructor "of" for models and requests needs magic methods in the class header to provide proper IDE support. By using the library as a dependency the magic methods were not correctly used by the IDE. Also the reflection used inside the OfTrait is not the best solution. So now all models and requests should have one or more named constructors which can be properly read by most IDE, don't require reflection for instantiation and can create instances without parameters which is helpful for testing purposes.
(d19a83c1)
Major refactoring of the http client handling. Sphere client uses now PSR http messages for internal request and response representation and ships with a guzzle5 and guzzle6 http client adapter which will be automatically used. It's also possible to register new http client adapters implementing Sphere\Core\Client\Adapter\AdapterInterface
How can I help you explore Laravel packages today?