Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Overwrite an existing plugin JS in Shopware 6

I am currently trying to overwrite a javascript file from an existing plugin.

I've been following the documentation but I am struggling with the path for the JS class to overwrite.

In the docs is an example code:

import CookiePermissionPlugin from 'src/plugin/cookie/cookie-permission.plugin';

export default class MyCookiePermission extends CookiePermissionPlugin {
}

So I implemented the following code:

import QuantityField from 'src/plugin/FilterRangeSlider/filter-range-slider.plugin';

export default class ExampleQuantityField extends QuantityField {

This code does not work for me, since the original file is in the vendor directory and my plugin is in the custom directory. When trying to compile (eg bin/build-storefront.sh) I receive the following error message:

Module not found: Error: Can't resolve 'src/plugin/FilterRangeSlider/filter-range-slider.plugin' in '<project root>/custom/plugins/ExampleProductFilter/src/Resources/app/storefront/src/filter-range-slider'

Any idea how I can import that class as stated in the docs?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Node.js provides a bunch of in-built file-system functionalities. The __dirname points to the root directory.

So, this should work.

import QuantityField from `${__dirname}/vendor/store.shopware.com/mmeesrangesliderpro/src/Resources/app/storefront/src/script/filter-range-slider.plugin`
about 4 years ago · Juan Pablo Isaza Report

0

My current solution is not really clean...

import QuantityField from '../../../../../../../../../vendor/store.shopware.com/mmeesrangesliderpro/src/Resources/app/storefront/src/script/filter-range-slider.plugin';

Isnt there any plugin root variable or something similar?

about 4 years ago · Juan Pablo Isaza Report

0

There is - I believe - no easier way to accomplish this.

If each plugin would extend the webpack config as described in

https://developer.shopware.com/docs/guides/plugins/plugins/administration/extending-webpack

const path = require('path');

module.exports = () => {
    return {
    resolve: {
        alias: {
            MmeesRangeSliderPro: path.join(__dirname, '..', 'src')
        }
    }
    };
};

The alias could be used instead of the Plugin Root.

But this is not the case, so the following is not working:

import QuantityField from 'MmeesRangeSliderPro/plugin/FilterRangeSlider/filter-range-slider.plugin';

You can add a console.log(webpackConfig) to the bottom of Resources/app/storefront/webpack.config.js to validate this.

   alias: {
      src: '/home/user/example/projects/example.de/vendor/shopware/storefront/Resources/app/storefront/src',
      assets: '/home/user/example/projects/example.de/vendor/shopware/storefront/Resources/app/storefront/assets',
      jquery: 'jquery/dist/jquery.slim',
      scss: '/home/user/example/projects/example.de/vendor/shopware/storefront/Resources/app/storefront/src/scss',
      vendor: '/home/user/example/projects/example.de/vendor/shopware/storefront/Resources/app/storefront/vendor'
    }

And those again to not really allow locating the module.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!