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

all.js problem with packed plugins when override Shopware core functionality #430

Open
arthur-ditegra opened this issue Nov 4, 2024 · 0 comments

Comments

@arthur-ditegra
Copy link

PHP Version

8.1

Shopware Version

6.5.8.10

Plugin Version

0.4.54

Actual behaviour

The Problem happens when installing the Plugin in an excising or newly created Shopware system. In this example, we override the off canvas cart:
PluginManager.override('OffCanvasCart', OverOffcanvasCart, '[data-offcanvas-cart]'); An Error is thrown when the packet part reaches o = l.Z.serialize(t);
l should be the off canvas cart or an Object. I am not sure there.
This is not the first time it has happened, somehow the packet all.js has some wrong Id's set.

Expected behaviour

The packed all.js should behave the same when packing a Plugins JavaScript into an all.js file.

Steps to Reproduce?

  • Just create a plugin and extend or override Shopware core code.

For this example, you can use this:

main.js

import TestOffcanvasCart from './plugin/test-offcanvas-cart/test-offcanvas-cart.plugin';

const PluginManager = window.PluginManager;
PluginManager.override('OffCanvasCart', TestOffcanvasCart, '[data-offcanvas-cart]');

test-offcanvas-cart.plugin.js.js

import OffcanvasCartPlugin from 'src/plugin/offcanvas-cart/offcanvas-cart.plugin';

export default class TestOffcanvasCartPlugin extends OffcanvasCartPlugin {

    _onChangeProductQuantity(event) {
        const select = event.target;
        const form = select.closest('form');
        const selector = this.options.cartItemSelector;
        this.$emitter.publish('onChangeProductQuantity');
        //
        const url = window.router['frontend.cart.offcanvas'];
        const _callback = () => {
            this.client.get(url, response => {
                this._updateOffCanvasContent(response);
                this._registerEvents();
            }, 'text/html');
        };
        this._fireRequest(form, selector, _callback);
    }
}
  • Pack this plugin with the CLI tool
  • Install the plugin and observer the log when you change the quantity of products inside the offcanvas-cart.

I hope this is enough information to reproduce.

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

No branches or pull requests

1 participant