docs icon indicating copy to clipboard operation
docs copied to clipboard

Add Webservice tutorial in (Modules) extension concept section

Open marsaldev opened this issue 2 years ago • 4 comments

Add new page about how to extend the Webservice resources through custom entity and module

Questions Answers
Branch? 1.7.x
Description? Chatting with a community member that needs to add informations accessible through webservice, I discover that there isn't a small tutorial on how to do through a module with a custom entity (using ObjectModel).
Fixed ticket? ~

marsaldev avatar Jul 13 '22 10:07 marsaldev

Thanks @marsaldev - I'll take a look this week ❤️

kpodemski avatar Aug 02 '22 20:08 kpodemski

Hello @marsaldev

I'm not in favor to usage of namespace for classes that extends legacy PrestaShop Core classes like ObjectModel.

This classes were designed to be in the global namespace, use it with a namespace can create issues with others legacy classes, like native legacy logger : https://github.com/PrestaShop/PrestaShop/issues/28617

And also various others pieces of code that will interact with it in legacy PrestaShop core can encountered issues cause it were designed only for global namespace.

So my recommendation is to keep classes that's extends legacy PrestaShop core classes in global namespace, so put your ObjectModel in modules/yourmodule/classes/Article.php

All new classes that's not extends legacy classes can be namespaced and placed in modules/yourmodule/src/ without issue.

Matt75 avatar Aug 04 '22 08:08 Matt75

Hi @marsaldev

I agree with @Matt75.

It's been reported a few times that having legacy classes hidden behind namespaces may be problematic in some undocumented scenarios.

Let's keep it simple and focus on handling WS inside a class without having the composer handling autoloader, etc.

kpodemski avatar Aug 16 '22 11:08 kpodemski

Got it! 😉 I'll update it 👍🏻 Thanks a lot @Matt75 @kpodemski

marsaldev avatar Aug 16 '22 13:08 marsaldev

Thank you, @marsaldev ❤️ I allowed myself to commit some minor improvements. Let's wait for the build to see how it looks, if it is ok we will need to have it in the PrestaShop 8 too :)

kpodemski avatar Sep 28 '22 20:09 kpodemski