Skip to content

Conversation

@mnocon
Copy link
Contributor

@mnocon mnocon commented Oct 24, 2024

Target: master, 4.6

Composer install fails on master: https://github.com/ibexa/documentation-developer/actions/runs/11455894682/job/31872858731

bacause of the new Core Search package.

This PR adjusts the code sample to take the new package into account.

I will also cherry-pick this to 4.6 - so that we do not recommend using the deprecated class from Product Catalog.

Before:
https://doc.ibexa.co/en/latest/commerce/order_management/order_management_api/#get-multiple-orders

After:
https://ez-systems-developer-documentation--2524.com.readthedocs.build/en/2524/commerce/order_management/order_management_api/#get-multiple-orders

@github-actions
Copy link

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/api/commerce/src/Command/OrderCommand.php

docs/commerce/order_management/order_management_api.md@20:``` php
docs/commerce/order_management/order_management_api.md@21:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 57, 61) =]]
docs/commerce/order_management/order_management_api.md@22:```

001⫶ $orderIdentifier = '2e897b31-0d7a-46d3-ba45-4eb65fe02790';
002⫶ $order = $this->orderService->getOrderByIdentifier($orderIdentifier);
003⫶
004⫶ $output->writeln(sprintf('Order %s has status %s', $orderIdentifier, $order->getStatus()));

docs/commerce/order_management/order_management_api.md@28:``` php
docs/commerce/order_management/order_management_api.md@29:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 63, 67) =]]
docs/commerce/order_management/order_management_api.md@30:```

001⫶ $orderId = 1;
002⫶ $order = $this->orderService->getOrder($orderId);
003⫶
004⫶ $output->writeln(sprintf('Order %d has status %s', $orderId, $order->getStatus()));

docs/commerce/order_management/order_management_api.md@37:``` php

code_samples/api/commerce/src/Command/OrderCommand.php

docs/commerce/order_management/order_management_api.md@20:``` php
docs/commerce/order_management/order_management_api.md@21:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 57, 61) =]]
docs/commerce/order_management/order_management_api.md@22:```

001⫶ $orderIdentifier = '2e897b31-0d7a-46d3-ba45-4eb65fe02790';
002⫶ $order = $this->orderService->getOrderByIdentifier($orderIdentifier);
003⫶
004⫶ $output->writeln(sprintf('Order %s has status %s', $orderIdentifier, $order->getStatus()));

docs/commerce/order_management/order_management_api.md@28:``` php
docs/commerce/order_management/order_management_api.md@29:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 63, 67) =]]
docs/commerce/order_management/order_management_api.md@30:```

001⫶ $orderId = 1;
002⫶ $order = $this->orderService->getOrder($orderId);
003⫶
004⫶ $output->writeln(sprintf('Order %d has status %s', $orderId, $order->getStatus()));

docs/commerce/order_management/order_management_api.md@37:``` php
docs/commerce/order_management/order_management_api.md@38:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 9, 13) =]][[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 21, 22) =]]
docs/commerce/order_management/order_management_api.md@38:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 8, 9) =]][[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 10, 14) =]]
docs/commerce/order_management/order_management_api.md@39:
docs/commerce/order_management/order_management_api.md@40:// ...
docs/commerce/order_management/order_management_api.md@41:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 116, 125) =]]
docs/commerce/order_management/order_management_api.md@42:```

docs/commerce/order_management/order_management_api.md@39:
docs/commerce/order_management/order_management_api.md@40:// ...
docs/commerce/order_management/order_management_api.md@41:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 116, 125) =]]
docs/commerce/order_management/order_management_api.md@42:```

001⫶use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery;
002⫶use Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\CompanyNameCriterion;
003⫶use Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\CustomerNameCriterion;
004⫶use Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\IdentifierCriterion;
005⫶use Ibexa\Contracts\ProductCatalog\Values\Common\Query\Criterion\LogicalOr;
001⫶use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\LogicalOr;
002⫶use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery;
003⫶use Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\CompanyNameCriterion;
004⫶use Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\CustomerNameCriterion;
005⫶use Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\IdentifierCriterion;
006⫶
007⫶
008⫶// ...
009⫶ $orderCriterions = [
010⫶ new IdentifierCriterion('c328773e-8daa-4465-86d5-4d7890f3aa86'),
011⫶ new CompanyNameCriterion('IBM'),
012⫶ new CustomerNameCriterion('foo_user'),
013⫶ ];
014⫶ $orderQuery = new OrderQuery(new LogicalOr(...$orderCriterions));
015⫶ $orders = $this->orderService->findOrders($orderQuery);
016⫶
017⫶ $output->writeln(sprintf('Found %d orders with provided criteria', count($orders)));

docs/commerce/order_management/order_management_api.md@49:``` php
docs/commerce/order_management/order_management_api.md@50:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 97, 108) =]]
docs/commerce/order_management/order_management_api.md@51:```

001⫶ $orderCreateStruct = new OrderCreateStruct(
002⫶ $user,
003⫶ $currency,
004⫶ $value,
005⫶ 'local_shop',
006⫶ $items
007⫶ );
008⫶
009⫶ $order = $this->orderService->createOrder($orderCreateStruct);
010⫶
011⫶ $output->writeln(sprintf('Created order with identifier %s', $order->getIdentifier()));

docs/commerce/order_management/order_management_api.md@59:``` php
docs/commerce/order_management/order_management_api.md@60:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 110, 114) =]]
docs/commerce/order_management/order_management_api.md@61:```

001⫶ $orderUpdateStruct = new OrderUpdateStruct('processed');
002⫶ $this->orderService->updateOrder($order, $orderUpdateStruct);
003⫶
004⫶ $output->writeln(sprintf('Changed order status to %s', $order->getStatus()));

006⫶
007⫶
008⫶// ...
009⫶ $orderCriterions = [
010⫶ new IdentifierCriterion('c328773e-8daa-4465-86d5-4d7890f3aa86'),
011⫶ new CompanyNameCriterion('IBM'),
012⫶ new CustomerNameCriterion('foo_user'),
013⫶ ];
014⫶ $orderQuery = new OrderQuery(new LogicalOr(...$orderCriterions));
015⫶ $orders = $this->orderService->findOrders($orderQuery);
016⫶
017⫶ $output->writeln(sprintf('Found %d orders with provided criteria', count($orders)));

docs/commerce/order_management/order_management_api.md@49:``` php
docs/commerce/order_management/order_management_api.md@50:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 97, 108) =]]
docs/commerce/order_management/order_management_api.md@51:```

001⫶ $orderCreateStruct = new OrderCreateStruct(
002⫶ $user,
003⫶ $currency,
004⫶ $value,
005⫶ 'local_shop',
006⫶ $items
007⫶ );
008⫶
009⫶ $order = $this->orderService->createOrder($orderCreateStruct);
010⫶
011⫶ $output->writeln(sprintf('Created order with identifier %s', $order->getIdentifier()));

docs/commerce/order_management/order_management_api.md@59:``` php
docs/commerce/order_management/order_management_api.md@60:[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 110, 114) =]]
docs/commerce/order_management/order_management_api.md@61:```

001⫶ $orderUpdateStruct = new OrderUpdateStruct('processed');
002⫶ $this->orderService->updateOrder($order, $orderUpdateStruct);
003⫶
004⫶ $output->writeln(sprintf('Changed order status to %s', $order->getStatus()));

Download colorized diff

@mnocon mnocon requested a review from a team October 25, 2024 07:10
@mnocon mnocon merged commit 81e5190 into master Oct 29, 2024
6 checks passed
@mnocon mnocon deleted the adjust-code-samples branch October 29, 2024 13:22
mnocon added a commit that referenced this pull request Oct 29, 2024
* Adjusted code samples after CoreSearch is introduced
* Adjusted code sample usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants