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

NEXT-31347 - BugFix: Update data type for AfterLineItemQuantityChangedEvent::getItems() #3392

Conversation

bhardwajakshit
Copy link
Contributor

@bhardwajakshit bhardwajakshit commented Oct 26, 2023

1. Why is this change necessary?

  • Expected behaviour
    AfterLineItemQuantityChangedEvent::getItems() should return array of Shopware\Core\Checkout\Cart\LineItem\LineItem or the return type of getItems() should be changed to Array of Arrays.

  • Actual behaviour
    AfterLineItemQuantityChangedEvent::getItems() returns an array of array.

2. What does this change do, exactly?

  • This change updates the return type of AfterLineItemQuantityChangedEvent::getItems()

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

  1. Add a Subscriber for AfterLineItemQuantityChangedEvent.

  2. Subscriber should call AfterLineItemQuantityChangedEvent::getItems()
    `class LineItemQuantityChangedSubscriber implements EventSubscriberInterface
    {
    public static function getSubscribedEvents(): array
    {
    return [
    AfterLineItemQuantityChangedEvent::class => 'onLineItemQuantityChange'
    ];
    }

    public function onLineItemQuantityChange(AfterLineItemQuantityChangedEvent $event): void
    {
    foreach ($event->getItems() as $itemToUpdate) {
    $lineItem->getPayload();
    }
    }
    }`

  3. Change Qty in Cart.

  4. Error appears cannot call getPayload() on array

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

Issue - [3390]

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.

🤖 Generated by Copilot at 4f80101

Modified the AfterLineItemQuantityChangedEvent class to include more details about the line items and their quantity changes. This allows event subscribers to access and use more information about the cart changes triggered by the event.

🤖 Generated by Copilot at 4f80101

  • Change the type of the items property and parameter in the AfterLineItemQuantityChangedEvent class to store additional information about the line items (link, link, link)

@CLAassistant
Copy link

CLAassistant commented Oct 26, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

github-actions bot commented Oct 26, 2023

Fails
🚫 The title `BugFix: Issue 3390 - Update data type for AfterLineItemQuantityChangedEvent::getItems()` does not match our requirements. Example: NEXT-00000 - My Title

@shopwareBot
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-31347

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

@bhardwajakshit bhardwajakshit changed the title BugFix: Issue 3390 - Update data type for AfterLineItemQuantityChangedEvent::getItems() BugFix: NEXT-31347 - Update data type for AfterLineItemQuantityChangedEvent::getItems() Oct 26, 2023
@bhardwajakshit bhardwajakshit changed the title BugFix: NEXT-31347 - Update data type for AfterLineItemQuantityChangedEvent::getItems() NEXT-31347 - BugFix: Update data type for AfterLineItemQuantityChangedEvent::getItems() Oct 26, 2023
@lernhart
Copy link
Member

lernhart commented Nov 2, 2023

I've just merged this, will be part of the next release. Thank you for your contribution @bhardwajakshit 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants