What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hi, could it be possible that you have intruced a new bug in spyker/sales?
Hi, could it be possible that you have intruced a new bug in spyker/sales? https://github.com/spryker/sales/blob/dc04c502ca4d11b6175dd680cf257d303fe17507/src/Spryker/Zed/Sales/Business/Model/Order/OrderHydrator.php#L160
Comments
-
@UK7KBE2JW i have the same problem in my b2b stack. i think there a two solutions for that.
Solution 1:
namespace Spryker\Zed\Sales\Business\Order; ... class OrderHydrator extends OrderHydratorWithoutMultiShipping { ... /** * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer * * @throws \Spryker\Zed\Sales\Business\Exception\InvalidSalesOrderException * * @return \Orm\Zed\Sales\Persistence\SpySalesOrder */ protected function getOrderEntity(OrderTransfer $orderTransfer) { $orderTransfer->requireIdSalesOrder() ->requireFkCustomer(); $customerTransfer = $this->getCustomerByFkCustomer($orderTransfer); $orderEntity = $this->queryContainer ->querySalesOrderDetailsWithoutShippingAddress($orderTransfer->getIdSalesOrder()) ->findOne(); if (!$this->isOrderApplicableForRetrieval($customerTransfer, $orderEntity)) { throw new InvalidSalesOrderException(sprintf( 'Order could not be found for ID %s and customer reference %s', $orderTransfer->getIdSalesOrder(), $orderTransfer->getCustomerReference() )); } return $orderEntity; } ... } namespace Spryker\Zed\Sales\Business\Model\Order; ... /** * @deprecated Use \Spryker\Zed\Sales\Business\Order\OrderHydrator instead. */ class OrderHydrator implements OrderHydratorInterface { /** * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer * * @throws \Spryker\Zed\Sales\Business\Exception\InvalidSalesOrderException * * @return \Orm\Zed\Sales\Persistence\SpySalesOrder */ protected function getOrderEntity(OrderTransfer $orderTransfer) { $orderTransfer->requireIdSalesOrder() ->requireFkCustomer(); $customerTransfer = $this->getCustomerByFkCustomer($orderTransfer); $orderEntity = $this->queryContainer ->querySalesOrderDetails($orderTransfer->getIdSalesOrder()) ->findOne(); if (!$this->isOrderApplicableForRetrieval($customerTransfer, $orderEntity)) { throw new InvalidSalesOrderException(sprintf( 'Order could not be found for ID %s and customer reference %s', $orderTransfer->getIdSalesOrder(), $orderTransfer->getCustomerReference() )); } return $orderEntity; } ... /** * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer * @param \Orm\Zed\Sales\Persistence\SpySalesOrder|null $orderEntity * * @return bool */ protected function isOrderApplicableForRetrieval( CustomerTransfer $customerTransfer, ?SpySalesOrder $orderEntity ): bool { if (!$orderEntity) { return false; } if ($customerTransfer->getCustomerReference() !== $orderEntity->getCustomerReference()) { return false; } return $this->isCustomerOrderAccessGranted($orderEntity, $customerTransfer); } }
Solution 2:
namespace Spryker\Zed\Sales\Business\Order; ... class OrderHydrator extends OrderHydratorWithoutMultiShipping { ... /** * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer * * @throws \Spryker\Zed\Sales\Business\Exception\InvalidSalesOrderException * * @return \Orm\Zed\Sales\Persistence\SpySalesOrder */ protected function getOrderEntity(OrderTransfer $orderTransfer) { $orderTransfer->requireIdSalesOrder() ->requireFkCustomer(); $customerTransfer = $this->getCustomerByFkCustomer($orderTransfer); $orderTransfer->setCustomer($customerTransfer); $orderEntity = $this->queryContainer ->querySalesOrderDetailsWithoutShippingAddress($orderTransfer->getIdSalesOrder()) ->findOne(); if (!$this->isOrderApplicableForRetrieval($orderTransfer, $customerTransfer, $orderEntity)) { throw new InvalidSalesOrderException(sprintf( 'Order could not be found for ID %s and customer reference %s', $orderTransfer->getIdSalesOrder(), $orderTransfer->getCustomerReference() )); } return $orderEntity; } ... } namespace Spryker\Zed\Sales\Business\Model\Order; ... /** * @deprecated Use \Spryker\Zed\Sales\Business\Order\OrderHydrator instead. */ class OrderHydrator implements OrderHydratorInterface { /** * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer * * @throws \Spryker\Zed\Sales\Business\Exception\InvalidSalesOrderException * * @return \Orm\Zed\Sales\Persistence\SpySalesOrder */ protected function getOrderEntity(OrderTransfer $orderTransfer) { $orderTransfer->requireIdSalesOrder() ->requireFkCustomer(); $customerTransfer = $this->getCustomerByFkCustomer($orderTransfer); $orderTransfer->setCustomer($customerTransfer); $orderEntity = $this->queryContainer ->querySalesOrderDetails($orderTransfer->getIdSalesOrder()) ->findOne(); if (!$this->isOrderApplicableForRetrieval($orderTransfer, $customerTransfer, $orderEntity)) { throw new InvalidSalesOrderException(sprintf( 'Order could not be found for ID %s and customer reference %s', $orderTransfer->getIdSalesOrder(), $orderTransfer->getCustomerReference() )); } return $orderEntity; } }
0 -
Solution 1 works for me, thx.
0 -
@UK7KBE2JW could you please share error stack trace?
0 -
@U0140NZMDTN i donβt understand why you use $orderTransfer->getCustomer()? you get the customerTransfer always over $customerTransfer = $this->getCustomerByFkCustomer($orderTransfer);. The method getCustomerByFkCustomer will throw an exception if customer transfer is not set.
0 -
These changes needs for sharing orders to other customers (company users with some permission, etc).
@UKBF1R1S50 -
protected function isOrderApplicableForRetrieval( OrderTransfer $orderTransfer, CustomerTransfer $customerTransfer, ?SpySalesOrder $orderEntity ): bool { if (!$orderEntity) { return false; } if ($customerTransfer->getCustomerReference() === $orderEntity->getCustomerReference()) { return true; } if (!$orderTransfer->getCustomer()) { return false; } return $this->isCustomerOrderAccessGranted($orderEntity, $orderTransfer->getCustomer()); }
Use this hot fix in project level, I will create bug ticket for this not-BC issue.
0 -
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer * * @return bool */ protected function isCustomerOrderAccessGranted(SpySalesOrder $orderEntity, CustomerTransfer $customerTransfer): bool { $orderTransfer = (new OrderTransfer())->fromArray($orderEntity->toArray(), true); if ($orderTransfer->getCustomerReference() === $customerTransfer->getCustomerReference()) { return true; } foreach ($this->customerOrderAccessCheckPlugins as $customerOrderAccessCheckPlugin) { if ($customerOrderAccessCheckPlugin->check($orderTransfer, $customerTransfer)) { return true; } } return false; }
0 -
Ok, thank you. When will the bugfix be released?
0 -
@U0140NZMDTN i donβt understand this fix. but if it works, iβll try it.
0 -
ASAP as our queue allows this.
0 -
$orderTransfer->getCustomer()
- this is customer who request order to retrieve (get from session). In most cases it's creator of this order.
But now it can be another customer who want's to see this order.0 -
@U0140NZMDTN but your line is duplicated. you can find it also in the method isCustomerOrderAccessGranted which will execute end the end of isOrderApplica⦠--> https://github.com/spryker/sales/blob/dc04c502ca4d11b6175dd680cf257d303fe17507/src/Spryker/Zed/Sales/Business/Model/Order/OrderHydrator.php#L612
0 -
@UKBF1R1S5 you right, in my hotfix we have duplication to avoid changes in method signature. In final bugticket we will provide better solution.
0 -
Cooel. Thx
0 -
Hi! This should have been fixed in https://github.com/spryker/sales/releases/tag/11.8.1.
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 65 Spryker News
- 879 Developer Corner
- 743 Spryker Development
- 84 Spryker Dev Environment
- 360 Spryker Releases
- 3 Oryx frontend framework
- 33 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 22 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 68 Spryker Safari Questions
- 50 Random