mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Fixes after CR
This commit is contained in:
parent
e82f4b06d4
commit
4173be56cb
9 changed files with 61 additions and 637 deletions
|
|
@ -1,393 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Tests\Api\Admin;
|
||||
|
||||
use Sylius\Bundle\ApiBundle\Serializer\ImageNormalizer;
|
||||
use Sylius\Component\Core\Model\ProductInterface;
|
||||
use Sylius\Tests\Api\JsonApiTestCase;
|
||||
use Sylius\Tests\Api\Utils\AdminUserLoginTrait;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class ProductsTest extends JsonApiTestCase
|
||||
{
|
||||
use AdminUserLoginTrait;
|
||||
|
||||
/** @test */
|
||||
public function it_gets_a_product(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFiles([
|
||||
'authentication/api_administrator.yaml',
|
||||
'channel.yaml',
|
||||
'product/product.yaml',
|
||||
]);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
/** @var ProductInterface $product */
|
||||
$product = $fixtures['product_mug'];
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: sprintf('/api/v2/admin/products/%s', $product->getCode()),
|
||||
server: $header,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/get_product_response',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_gets_products(): void
|
||||
{
|
||||
$this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'product/product.yaml']);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: '/api/v2/admin/products',
|
||||
server: $header,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/get_products_response',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_gets_products_with_image_filter(): void
|
||||
{
|
||||
$this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'product/product.yaml']);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: '/api/v2/admin/products',
|
||||
parameters: [ImageNormalizer::FILTER_QUERY_PARAMETER => 'sylius_small'],
|
||||
server: $header,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/get_products_response_with_image_filter',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_creates_a_product(): void
|
||||
{
|
||||
$this->loadFixturesFromFiles([
|
||||
'authentication/api_administrator.yaml',
|
||||
'taxonomy.yaml',
|
||||
'product/product_option.yaml',
|
||||
'product/product_attribute.yaml',
|
||||
]);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
$this->client->request(
|
||||
method: 'POST',
|
||||
uri: '/api/v2/admin/products',
|
||||
server: $header,
|
||||
content: json_encode([
|
||||
'code' => 'MUG',
|
||||
'variantSelectionMethod' => ProductInterface::VARIANT_SELECTION_MATCH,
|
||||
'enabled' => true,
|
||||
'options' => [
|
||||
'/api/v2/admin/product-options/COLOR',
|
||||
],
|
||||
'mainTaxon' => '/api/v2/admin/taxons/MUG',
|
||||
'channels' => [
|
||||
'/api/v2/admin/channels/WEB_GB',
|
||||
],
|
||||
'attributes' => [[
|
||||
'attribute' => '/api/v2/admin/product-attributes/dishwasher_safe',
|
||||
'value' => true,
|
||||
]],
|
||||
'translations' => [
|
||||
'en_US' => [
|
||||
'slug' => 'mug',
|
||||
'name' => 'Mug',
|
||||
'description' => 'This is a mug',
|
||||
'shortDescription' => 'Short mug description',
|
||||
'metaKeywords' => 'mug',
|
||||
'metaDescription' => 'Mug description',
|
||||
],
|
||||
'pl_PL' => [
|
||||
'slug' => 'kubek',
|
||||
'name' => 'Kubek',
|
||||
'description' => 'To jest kubek',
|
||||
'shortDescription' => 'Krótki opis kubka',
|
||||
'metaKeywords' => 'kubek',
|
||||
'metaDescription' => 'Opis kubka',
|
||||
],
|
||||
],
|
||||
], \JSON_THROW_ON_ERROR),
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/post_product_response',
|
||||
Response::HTTP_CREATED,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_does_not_create_a_product_without_required_data(): void
|
||||
{
|
||||
$this->loadFixturesFromFile('authentication/api_administrator.yaml');
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
$this->client->request(
|
||||
method: 'POST',
|
||||
uri: '/api/v2/admin/products',
|
||||
server: $header,
|
||||
content: '{}',
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/post_product_without_required_data_response',
|
||||
Response::HTTP_UNPROCESSABLE_ENTITY,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_does_not_create_a_product_with_invalid_translation_locale(): void
|
||||
{
|
||||
$this->loadFixturesFromFile('authentication/api_administrator.yaml');
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
$this->client->request(
|
||||
method: 'POST',
|
||||
uri: '/api/v2/admin/products',
|
||||
server: $header,
|
||||
content: json_encode([
|
||||
'code' => 'MUG',
|
||||
'translations' => [
|
||||
'en_US' => [
|
||||
'slug' => 'mug',
|
||||
'name' => 'Mug',
|
||||
],
|
||||
'a' => [
|
||||
'slug' => 'kubek',
|
||||
'name' => 'Kubek',
|
||||
],
|
||||
],
|
||||
], \JSON_THROW_ON_ERROR),
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/post_product_with_invalid_translation_locale',
|
||||
Response::HTTP_UNPROCESSABLE_ENTITY,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_does_not_create_a_product_when_locale_differs_from_key(): void
|
||||
{
|
||||
$this->loadFixturesFromFile('authentication/api_administrator.yaml');
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
$this->client->request(
|
||||
method: 'POST',
|
||||
uri: '/api/v2/admin/products',
|
||||
server: $header,
|
||||
content: json_encode([
|
||||
'code' => 'MUG',
|
||||
'translations' => [
|
||||
'en_US' => [
|
||||
'slug' => 'mug',
|
||||
'name' => 'Mug',
|
||||
'locale' => 'locale',
|
||||
],
|
||||
],
|
||||
], \JSON_THROW_ON_ERROR),
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/post_product_when_locale_differs_from_key',
|
||||
Response::HTTP_UNPROCESSABLE_ENTITY,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_updates_the_existing_product(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFiles([
|
||||
'authentication/api_administrator.yaml',
|
||||
'channel.yaml',
|
||||
'product/product.yaml',
|
||||
'product/product_attribute.yaml',
|
||||
]);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
/** @var ProductInterface $product */
|
||||
$product = $fixtures['product_mug'];
|
||||
|
||||
$this->client->request(
|
||||
method: 'PUT',
|
||||
uri: sprintf('/api/v2/admin/products/%s', $product->getCode()),
|
||||
server: $header,
|
||||
content: json_encode([
|
||||
'enabled' => false,
|
||||
'mainTaxon' => '/api/v2/admin/taxons/CAPS',
|
||||
'channels' => [
|
||||
'/api/v2/admin/channels/MOBILE',
|
||||
],
|
||||
'attributes' => [
|
||||
[
|
||||
'@id' => sprintf(
|
||||
'/api/v2/admin/product-attribute-values/%s',
|
||||
$product->getAttributeByCodeAndLocale('MATERIAL', 'en_US')->getId(),
|
||||
),
|
||||
'attribute' => '/api/v2/admin/product-attributes/MATERIAL',
|
||||
'value' => 'Cotton',
|
||||
'localeCode' => 'en_US',
|
||||
],
|
||||
[
|
||||
'@id' => sprintf(
|
||||
'/api/v2/admin/product-attribute-values/%s',
|
||||
$product->getAttributeByCodeAndLocale('MATERIAL', 'pl_PL')->getId(),
|
||||
),
|
||||
'attribute' => '/api/v2/admin/product-attributes/MATERIAL',
|
||||
'value' => 'Bawełna',
|
||||
'localeCode' => 'pl_PL',
|
||||
],
|
||||
[
|
||||
'attribute' => '/api/v2/admin/product-attributes/dishwasher_safe',
|
||||
'value' => true,
|
||||
],
|
||||
],
|
||||
'translations' => [
|
||||
'en_US' => [
|
||||
'@id' => sprintf('/api/v2/admin/product-translations/%s', $product->getTranslation('en_US')->getId()),
|
||||
'slug' => 'caps/cap',
|
||||
'name' => 'Cap',
|
||||
'description' => 'This is a cap',
|
||||
'shortDescription' => 'Short cap description',
|
||||
'metaKeywords' => 'cap',
|
||||
'metaDescription' => 'Cap description',
|
||||
],
|
||||
'pl_PL' => [
|
||||
'@id' => sprintf('/api/v2/admin/product-translations/%s', $product->getTranslation('pl_PL')->getId()),
|
||||
'slug' => 'czapki/czapka',
|
||||
'name' => 'Czapka',
|
||||
'description' => 'To jest czapka',
|
||||
'shortDescription' => 'Krótki opis czapki',
|
||||
'metaKeywords' => 'czapka',
|
||||
'metaDescription' => 'Opis czapki',
|
||||
],
|
||||
],
|
||||
], \JSON_THROW_ON_ERROR),
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/put_product_response',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_does_not_update_a_product_with_duplicate_locale_translation(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFiles([
|
||||
'authentication/api_administrator.yaml',
|
||||
'channel.yaml',
|
||||
'product/product.yaml',
|
||||
]);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
/** @var ProductInterface $product */
|
||||
$product = $fixtures['product_mug'];
|
||||
|
||||
$this->client->request(
|
||||
method: 'PUT',
|
||||
uri: sprintf('/api/v2/admin/products/%s', $product->getCode()),
|
||||
server: $header,
|
||||
content: json_encode([
|
||||
'translations' => [
|
||||
'en_US' => [
|
||||
'@id' => sprintf('/api/v2/admin/product-translations/%s', $product->getTranslation('en_US')->getId()),
|
||||
'slug' => 'caps/cap',
|
||||
'name' => 'Cap',
|
||||
],
|
||||
'pl_PL' => [
|
||||
'name' => 'Czapka',
|
||||
],
|
||||
],
|
||||
], \JSON_THROW_ON_ERROR),
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/put_product_with_duplicate_locale_translation',
|
||||
Response::HTTP_UNPROCESSABLE_ENTITY,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_deletes_the_product(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFiles([
|
||||
'authentication/api_administrator.yaml',
|
||||
'channel.yaml',
|
||||
'product/product.yaml',
|
||||
]);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
/** @var ProductInterface $product */
|
||||
$product = $fixtures['product_socks'];
|
||||
|
||||
$this->client->request(
|
||||
method: 'DELETE',
|
||||
uri: sprintf('/api/v2/admin/products/%s', $product->getCode()),
|
||||
server: $header,
|
||||
);
|
||||
|
||||
$this->assertResponseCode($this->client->getResponse(), Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_does_not_delete_the_product_in_use(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFiles([
|
||||
'authentication/api_administrator.yaml',
|
||||
'channel.yaml',
|
||||
'product/product.yaml',
|
||||
]);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
/** @var ProductInterface $product */
|
||||
$product = $fixtures['product_cap'];
|
||||
|
||||
$this->client->request(
|
||||
method: 'DELETE',
|
||||
uri: sprintf('/api/v2/admin/products/%s', $product->getCode()),
|
||||
server: $header,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/product/delete_product_in_use_response',
|
||||
Response::HTTP_UNPROCESSABLE_ENTITY,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,210 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Tests\Api\Shop;
|
||||
|
||||
use Sylius\Component\Product\Model\ProductInterface;
|
||||
use Sylius\Tests\Api\JsonApiTestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class ProductsTest extends JsonApiTestCase
|
||||
{
|
||||
/** @test */
|
||||
public function it_preserves_query_param_when_redirecting_from_product_slug_to_product_code(): void
|
||||
{
|
||||
$this->loadFixturesFromFile('product/product_variant_with_original_price.yaml');
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: '/api/v2/shop/products-by-slug/mug?paramName=paramValue',
|
||||
server: self::CONTENT_TYPE_HEADER,
|
||||
);
|
||||
$response = $this->client->getResponse();
|
||||
|
||||
$this->assertEquals('/api/v2/shop/products/MUG?paramName=paramValue', $response->headers->get(('Location')));
|
||||
$this->assertResponseCode($response, Response::HTTP_MOVED_PERMANENTLY);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_returns_product_with_translations_in_default_locale(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFile('product/product_with_many_locales.yaml');
|
||||
|
||||
/** @var ProductInterface $product */
|
||||
$product = $fixtures['product_mug'];
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: sprintf('/api/v2/shop/products/%s', $product->getCode()),
|
||||
server: self::CONTENT_TYPE_HEADER,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'shop/product/get_product_with_default_locale_translation',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @dataProvider getGermanLocales
|
||||
*/
|
||||
public function it_returns_product_with_translations_in_locale_from_header(string $germanLocale): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFile('product/product_with_many_locales.yaml');
|
||||
|
||||
/** @var ProductInterface $product */
|
||||
$product = $fixtures['product_mug'];
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: sprintf('/api/v2/shop/products/%s', $product->getCode()),
|
||||
server: [
|
||||
'CONTENT_TYPE' => 'application/ld+json',
|
||||
'HTTP_ACCEPT' => 'application/ld+json',
|
||||
'HTTP_ACCEPT_LANGUAGE' => $germanLocale,
|
||||
],
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'shop/product/get_product_with_de_DE_locale_translation',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_returns_products_collection(): void
|
||||
{
|
||||
$this->loadFixturesFromFiles(['product/product_variant_with_original_price.yaml']);
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: '/api/v2/shop/products',
|
||||
server: self::CONTENT_TYPE_HEADER,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'shop/product/get_products_collection_response',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_returns_products_collection_with_only_available_associations(): void
|
||||
{
|
||||
$this->loadFixturesFromFile('product/products_with_associations.yaml');
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: '/api/v2/shop/products',
|
||||
server: self::CONTENT_TYPE_HEADER,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'shop/product/get_products_collection_with_associations_response',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_returns_products_with_reviews(): void
|
||||
{
|
||||
$this->loadFixturesFromFiles(['channel.yaml', 'product/product.yaml']);
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: '/api/v2/shop/products',
|
||||
server: $this->headerBuilder()->withJsonLdContentType()->withJsonLdAccept()->build(),
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'shop/product/get_products_with_reviews',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_returns_product_item_with_only_available_associations(): void
|
||||
{
|
||||
$this->loadFixturesFromFile('product/products_with_associations.yaml');
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: '/api/v2/shop/products/MUG',
|
||||
server: self::CONTENT_TYPE_HEADER,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'shop/product/get_product_with_default_locale_translation',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @dataProvider getPolishLocales
|
||||
*/
|
||||
public function it_returns_product_attributes_collection_with_translations_in_locale_from_header(
|
||||
string $polishLocale,
|
||||
): void {
|
||||
$this->loadFixturesFromFiles(['channel.yaml', 'product/product_attribute.yaml']);
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: sprintf('/api/v2/shop/products/%s/attributes', 'MUG_SW'),
|
||||
server: array_merge(self::CONTENT_TYPE_HEADER, ['HTTP_ACCEPT_LANGUAGE' => $polishLocale]),
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'shop/product/get_product_attributes_collection_response',
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_returns_paginated_attributes_collection(): void
|
||||
{
|
||||
$this->loadFixturesFromFiles(['channel.yaml', 'product/product_attribute.yaml']);
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: sprintf('/api/v2/shop/products/%s/attributes', 'MUG_SW'),
|
||||
parameters: ['itemsPerPage' => 2],
|
||||
server: array_merge(self::CONTENT_TYPE_HEADER, ['HTTP_ACCEPT_LANGUAGE' => 'pl_PL']),
|
||||
);
|
||||
|
||||
$this->assertCount(2, json_decode($this->client->getResponse()->getContent(), true)['hydra:member']);
|
||||
}
|
||||
|
||||
public function getGermanLocales(): iterable
|
||||
{
|
||||
yield ['de_DE']; // Locale code syntax
|
||||
yield ['de-DE']; // RFC 4647 and RFC 3066
|
||||
yield ['DE-DE']; // RFC 4647 and RFC 3066
|
||||
yield ['de-de']; // RFC 4647 and RFC 3066
|
||||
}
|
||||
|
||||
public function getPolishLocales(): iterable
|
||||
{
|
||||
yield ['pl_PL']; // Locale code syntax
|
||||
yield ['pl-PL']; // RFC 4647 and RFC 3066
|
||||
yield ['PL-PL']; // RFC 4647 and RFC 3066
|
||||
yield ['pl-pl']; // RFC 4647 and RFC 3066
|
||||
}
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
<filter>sylius.api.catalog_promotion_enabled_filter</filter>
|
||||
<filter>sylius.api.catalog_promotion_start_date_filter</filter>
|
||||
<filter>sylius.api.catalog_promotion_end_date_filter</filter>
|
||||
<filter>Sylius\Bundle\ApiBundle\Filter\Doctrine\ChannelsAwareChannelFilter</filter>
|
||||
<filter>sylius.api.channel_aware_filter</filter>
|
||||
<filter>sylius.api.order_filter.code</filter>
|
||||
<filter>sylius.api.order_filter.name</filter>
|
||||
<filter>sylius.api.order_filter.start_date</filter>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0 https://api-platform.com/schema/metadata/resources-3.0.xsd"
|
||||
>
|
||||
<resource class="Sylius\Component\Core\Model\Product" shortName="Product" processor="Sylius\Bundle\ApiBundle\StateProcessor\ProductProcessor">
|
||||
<resource class="Sylius\Component\Core\Model\Product" shortName="Product" processor="sylius_api.state_processor.delete.product">
|
||||
<validationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
|
|
@ -48,8 +48,8 @@
|
|||
<filter>sylius.api.product_name_filter</filter>
|
||||
<filter>sylius.api.product_order_filter</filter>
|
||||
<filter>sylius.api.product_taxon_code_filter</filter>
|
||||
<filter>Sylius\Bundle\ApiBundle\Filter\Doctrine\ChannelsAwareChannelFilter</filter>
|
||||
<filter>Sylius\Bundle\ApiBundle\Filter\Doctrine\TranslationOrderNameAndLocaleFilter</filter>
|
||||
<filter>sylius.api.channel_aware_filter</filter>
|
||||
<filter>sylius.api.translation_order_and_locale_filter</filter>
|
||||
</filters>
|
||||
<openapiContext>
|
||||
<values>
|
||||
|
|
@ -87,9 +87,9 @@
|
|||
<filter>sylius.api.product_name_filter</filter>
|
||||
<filter>sylius.api.product_order_filter</filter>
|
||||
<filter>sylius.api.product_taxon_code_filter</filter>
|
||||
<filter>Sylius\Bundle\ApiBundle\Filter\Doctrine\ProductPriceOrderFilter</filter>
|
||||
<filter>Sylius\Bundle\ApiBundle\Filter\Doctrine\TranslationOrderNameAndLocaleFilter</filter>
|
||||
<filter>Sylius\Bundle\ApiBundle\Filter\Doctrine\TaxonFilter</filter>
|
||||
<filter>sylius.api.product_price_order_filter</filter>
|
||||
<filter>sylius.api.translation_order_and_locale_filter</filter>
|
||||
<filter>sylius.api.taxon_filter</filter>
|
||||
</filters>
|
||||
<openapiContext>
|
||||
<values>
|
||||
|
|
@ -276,7 +276,7 @@
|
|||
</operations>
|
||||
</resource>
|
||||
|
||||
<resource class="Sylius\Component\Core\Model\Product" uriTemplate="/admin/products/{code}/images">
|
||||
<resource class="Sylius\Component\Core\Model\ProductImage" uriTemplate="/admin/products/{code}/images">
|
||||
<uriVariables>
|
||||
<uriVariable parameterName="code" fromClass="Sylius\Component\Core\Model\Product" fromProperty="images"/>
|
||||
</uriVariables>
|
||||
|
|
@ -305,24 +305,4 @@
|
|||
</operation>
|
||||
</operations>
|
||||
</resource>
|
||||
|
||||
<resource class="Sylius\Component\Product\Model\ProductAttributeValue" uriTemplate="/shop/products/{code}/attributes">
|
||||
<uriVariables>
|
||||
<uriVariable parameterName="code" fromClass="Sylius\Component\Core\Model\Product" fromProperty="attributes"/>
|
||||
</uriVariables>
|
||||
<operations>
|
||||
<operation class="ApiPlatform\Metadata\GetCollection" provider="Sylius\Bundle\ApiBundle\StateProvider\ProductAttributesProvider">
|
||||
<normalizationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
<values>
|
||||
<value>sylius:shop:product_attribute_value:show</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</normalizationContext>
|
||||
</operation>
|
||||
</operations>
|
||||
</resource>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -62,4 +62,22 @@
|
|||
</operations>
|
||||
</resource>
|
||||
|
||||
<resource class="Sylius\Component\Product\Model\ProductAttributeValue" uriTemplate="/shop/products/{code}/attributes">
|
||||
<uriVariables>
|
||||
<uriVariable parameterName="code" fromClass="Sylius\Component\Core\Model\Product" fromProperty="attributes"/>
|
||||
</uriVariables>
|
||||
<operations>
|
||||
<operation class="ApiPlatform\Metadata\GetCollection" provider="sylius_api.state_provider.shop.product_attributes">
|
||||
<normalizationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
<values>
|
||||
<value>sylius:shop:product_attribute_value:show</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</normalizationContext>
|
||||
</operation>
|
||||
</operations>
|
||||
</resource>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -256,4 +256,33 @@
|
|||
</operations>
|
||||
</resource>
|
||||
|
||||
<resource class="Sylius\Component\Core\Model\ProductImage" uriTemplate="/admin/products/{code}/images">
|
||||
<uriVariables>
|
||||
<uriVariable parameterName="code" fromClass="Sylius\Component\Core\Model\Product" fromProperty="images"/>
|
||||
</uriVariables>
|
||||
<operations>
|
||||
<operation class="ApiPlatform\Metadata\GetCollection">
|
||||
<openapiContext>
|
||||
<values>
|
||||
<value name="parameters">
|
||||
<values>
|
||||
<value name="imageFilter">
|
||||
<values>
|
||||
<value name="name">imageFilter</value>
|
||||
<value name="in">query</value>
|
||||
<value name="description">Provide one of supported image liip imagine filters</value>
|
||||
<value name="schema">
|
||||
<values>
|
||||
<value name="type">string</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</openapiContext>
|
||||
</operation>
|
||||
</operations>
|
||||
</resource>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\TaxonFilter" public="true">
|
||||
<service id="sylius.api.taxon_filter" class="Sylius\Bundle\ApiBundle\Filter\Doctrine\TaxonFilter" public="true">
|
||||
<argument type="service" id="doctrine" />
|
||||
<argument type="service" id="api_platform.symfony.iri_converter" />
|
||||
<tag name="api_platform.filter" />
|
||||
|
|
@ -205,7 +205,7 @@
|
|||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\TranslationOrderNameAndLocaleFilter" public="true">
|
||||
<service id="sylius.api.translation_order_and_locale_filter" class="Sylius\Bundle\ApiBundle\Filter\Doctrine\TranslationOrderNameAndLocaleFilter" public="true">
|
||||
<argument type="service" id="doctrine" />
|
||||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
|
@ -222,7 +222,7 @@
|
|||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\ProductPriceOrderFilter" public="true">
|
||||
<service id="sylius.api.product_price_order_filter" class="Sylius\Bundle\ApiBundle\Filter\Doctrine\ProductPriceOrderFilter" public="true">
|
||||
<argument type="service" id="doctrine" />
|
||||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
|
@ -275,7 +275,7 @@
|
|||
<!-- <tag name="api_platform.filter" />-->
|
||||
<!-- </service>-->
|
||||
|
||||
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\ChannelsAwareChannelFilter" public="true">
|
||||
<service id="sylius.api.channel_aware_filter" class="Sylius\Bundle\ApiBundle\Filter\Doctrine\ChannelsAwareChannelFilter" public="true">
|
||||
<argument type="service" id="api_platform.symfony.iri_converter" />
|
||||
<argument type="service" id="doctrine" />
|
||||
<tag name="api_platform.filter" />
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
<tag name="api_platform.state_processor" />
|
||||
</service>
|
||||
|
||||
<service id="Sylius\Bundle\ApiBundle\StateProcessor\ProductProcessor">
|
||||
<service id="sylius_api.state_processor.delete.product" class="Sylius\Bundle\ApiBundle\StateProcessor\ProductProcessor">
|
||||
<argument type="service" id="api_platform.doctrine.orm.state.persist_processor" />
|
||||
<argument type="service" id="api_platform.doctrine.orm.state.remove_processor" />
|
||||
<tag name="api_platform.state_processor" />
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
<tag name="api_platform.state_provider" priority="10" />
|
||||
</service>
|
||||
|
||||
<service id="Sylius\Bundle\ApiBundle\StateProvider\ProductAttributesProvider">
|
||||
<service id="sylius_api.state_provider.shop.product_attributes" class="Sylius\Bundle\ApiBundle\StateProvider\ProductAttributesProvider">
|
||||
<argument type="tagged_iterator" tag="api_platform.doctrine.orm.query_extension.collection" />
|
||||
<argument type="service" id="sylius.repository.product_attribute_value" />
|
||||
<argument type="service" id="sylius.context.locale" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue