st3ff3n Posted May 3 Share Posted May 3 (edited) Hello, I need an override for /src/Adapter/Order/Refund/VoucherGenerator I have already tried it with these instructionshttps://www.prestashop.com/forums/topic/1040771-177-how-should-we-override-srcadapter-adminproductdataprovider/?do=findComment&comment=3357023 unfortunately nothing happened. The goal is that the voucher code is changed, automatically assigned to the store in which the purchase was made in the case of a multishop and the link to the e-mail is to be released. Can an adapter be provided with an override? What other solutions are there? Edited May 3 by st3ff3n (see edit history) Link to comment Share on other sites More sharing options...
Andrei H Posted May 6 Share Posted May 6 Hello, Yes, you can override adapters. In our case, the problem is most likely one of the following: - you did not provide the same service name as the original file uses. This is the name you will need to use in your services.yml: prestashop.adapter.order.refund.voucher_generator - you did not run 'composer dumpautoload' I also built a small module that overrides that class. You can find it attached below. Once the module is installed, when you generate a new voucher, you will see that the message from the constructor is dumped. The other option is to use a decorator, where you basically add functionality on top of the existing one. If you want to change some logic in the 'generateVoucher' method, as opposed to calling that and additionally adding your logic, this approach cannot be used. vouchergeneratoroverride.zip Link to comment Share on other sites More sharing options...
st3ff3n Posted May 8 Author Share Posted May 8 Hello, Thank you very much. That helped and I was able to add my own logic. In this case, renaming the voucher code, removing the personalization and assigning it to a specific store in a multishop installation. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now