Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add order criteria event to OrderRoute #3683

Closed

Conversation

tomaodovic
Copy link
Contributor

1. Why is this change necessary?

Currently it is not possible to modify the order criteria inside the OrderRoute.

2. What does this change do, exactly?

Add criteria event to modify the criteria.

3. Describe each step to reproduce the issue or behaviour.

-

4. Please link to the relevant issues (if any).

-

5. Checklist

  • I have rebased my changes to remove merge conflicts
  • I have written tests and verified that they fail without my change
  • I have created a changelog file with all necessary information about my changes
  • I have written or adjusted the documentation according to my changes
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I have read the contribution requirements and fulfil them.

@CLAassistant
Copy link

CLAassistant commented Apr 23, 2024

CLA assistant check
All committers have signed the CLA.

@mstegmeyer
Copy link
Contributor

As with all other Store API routes, it is possible to modify the Criteria by decorating the Route:
https://developer.shopware.com/docs/guides/plugins/plugins/framework/store-api/override-existing-route.html

Other routes, such as the ProductDetailRoute do not have such events as well. What do you think, @lernhart ?

@tomaodovic
Copy link
Contributor Author

The problem is, that in our use case we need to remove the order.salesChannelId filter from the criteria. Which is added inside of the route. Therefore decorating the route is not a viable solution for us.

return $this->criteria;
}

public function getContext(): SalesChannelContext
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be better, wouldn't it? Like in many other Events

public function getContext(): Context
{
    return $this->salesChannelContext->getContext();
}

public function getSalesChannelContext(): SalesChannelContext
{
    return $this->salesChannelContext;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just adjusted the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing use Shopware\Core\Framework\Context;?

@tomaodovic tomaodovic force-pushed the feat/adding-order-criteria-event branch 2 times, most recently from 92b9d30 to 970f6b2 Compare April 29, 2024 13:37
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Contracts\EventDispatcher\Event;

class OrderCriteriaEvent extends Event
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as icing on the cake, could you implement \Shopware\Core\Framework\Event\ShopwareSalesChannelEvent here? Then we will import it 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added.

@tomaodovic tomaodovic force-pushed the feat/adding-order-criteria-event branch from 970f6b2 to 5a37851 Compare May 7, 2024 08:28
@shopware-github-importer
Copy link

Hello,

thank you for creating this pull request.
I have opened an issue on our Issue Tracker for you. See the issue link: https://issues.shopware.com/issues/NEXT-36064

Please use this issue to track the state of your pull request.

@mstegmeyer
Copy link
Contributor

Your PR has been merged, thank you for your contribution 🎉 💙

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.

None yet

4 participants