Prestashop: Doctrine Entity miss MultiLang easy-optin feature

Created on 31 Jul 2019  路  12Comments  路  Source: PrestaShop/PrestaShop

New prestashop 1.7.6 features for doctrine entity are nice,
but doctrine, per-se, don't has a way to handle multi-language content.

Any plan to add this feature?Doctrine is unusable on real cases without adding some ways to handle (setter/getter) the translated text.

Improvement waiting for dev

Most helpful comment

@sam-pires Hi! Samuel - nice to see you here, and thank you that you care ;)

We wait for reply, because we simply cannot work. We see few ways, and even we don't know which one is right:

  • if PrestaShop stay on _lang and _shop structure? But how it works with Symfony?
  • PrestaShop will use another system? How it will work?

I can't believe that among so many people working on this project, no one thought about the fact that PrestaShop must use more than one language, before the depreciated of ObjectModel. Why ObjectModel is depreciated, if there is nothing instead?

All 12 comments

Ping @samuel-pires, @marionf

@PrestaShop/prestashop-core-developers, what do you think?

@Bonobomagno you can manage multi-language content "by hand" by creating a OneToMany relation to another entity dedicated to store the multi-language content

@Bonobomagno you can manage multi-language content "by hand" by creating a OneToMany relation to another entity dedicated to store the multi-language content

Ofc. but why i have to create a new way to do things only because of a basic feature miss?
Also, this is pretty hard to split in a trait/ baseEntity class because of annotation.
There is a need for doctrine extensions, they can handle translations using just annotation.

Otherwise..why use doctrine if the main feature (annotation and entity manager) are unusable?

Is there any chance for a developer reply? @marionf

We need you guys here 馃檪 @PrestaShop/prestashop-core-developers

@sam-pires Hi! Samuel - nice to see you here, and thank you that you care ;)

We wait for reply, because we simply cannot work. We see few ways, and even we don't know which one is right:

  • if PrestaShop stay on _lang and _shop structure? But how it works with Symfony?
  • PrestaShop will use another system? How it will work?

I can't believe that among so many people working on this project, no one thought about the fact that PrestaShop must use more than one language, before the depreciated of ObjectModel. Why ObjectModel is depreciated, if there is nothing instead?

Hey good to see you here @kvokul, and @polo195pl as well, how are you doing since Warszawa?

It's always interesting to have this kind of questions 馃憤
Ping @eternoendless, I guess you are the one who can best answer it.

I think there's a big misunderstanding here.

Why ObjectModel is depreciated, if there is nothing instead?

First of all, we intend on dropping ObjectModel in favor of something else like Doctrine, but this won't happen right now. We're planning on doing it on a _later_, not yet defined major version of PrestaShop. We hope it will be on the next one, but its development won't start at least until after 1.7.9 is feature frozen, which means about 18 months from now at the earliest. And that's if and only if there isn't another minor 1.7 version after that, which would push the next major 6 months further away.

We suggest developers to use Doctrine because a lot of them already use it in other projects and find it useful, and because at the moment it's the best candidate for replacing ObjectModel in the future. The Core is still using ObjectModel and will need to switch completely to Doctrine (or whatever other path we choose) before ObjectModel is removed, so of course we'll have to think about this by then because the Core will need it.

Even if ObjectModel will definitely be removed in the future, you can safely continue using it for now, especially if Doctrine doesn't suit your needs. Worst case scenario, you'll need to update your modules in a couple years. Just try not to _extend_ the Core tables if you can avoid it.

I think it's no use to start discussing right now about how will we fully replace features like multi language and multi shop support, it's too soon.

Of course, you're absolutely welcome to participate in this decision and suggest your ideas.

Hi everyone,

first I'm glad that you are interesting in using Doctrine in your module 馃槈

Then I wanted to clarify a few things, ObjectModel is not deprecated yet, we still use it in the core and it's still available in module, nothing has changed about that. Though it's true we would like to get rid of it a some point, it won't be before the next major version at least. So you can safely keep using it.

Now, in 1.7.6 we indeed offered the possibility to use Doctrine in modules, because it's a good alternative to ObjectModel but it was not easy to use in modules. I admit it's probably not perfect yet especially regarding the translatable entities.

I like the idea of using annotation to configure the entities, we don't have such annotations integrated in PrestaShop but I don't think we need to develop it, some doctrine extensions already exist to manage this feature. I'm thinking about http://atlantic18.github.io/DoctrineExtensions/doc/translatable.html (although I'm sure others exist). It allows to annotate translated fields, and to specify a dedicated translation class (therefore a table) which would match the current database structure in PrestaShop.

It might be included in a module, although I'm not 100% sure about that since I didn't try. It might be complicated for the module to add this extension to the kernel. Adding extension or bundle from modules is also something that is lacking but we are thinking about it. Here is an issue about it https://github.com/PrestaShop/PrestaShop/issues/14541

The thing is we already many tasks on our shoulder, some are more prioritized than others (migration, bug fixing, merchant features, ...). But the more we get requests/issues like this one the easier it will be to integrate cool stuffs for developers 馃槈

So tldr; you can try using the doctrine extension, I'm interested in feedback if you try (wether you succeed or not). Also if people have other suggestions for doctrine extension that manage this behavior. And on my side I will personally try to "push" this feature in the 1.7.8 if possible, though I can't guaranty it 馃槣 I added this in the "Modern modules" epic https://github.com/PrestaShop/PrestaShop/issues/15255

Our problem starts when we try to use files in multilang form, based on ObjectModel. There was only problem: answers. Suggestion was simple: use Doctrine, there is impossible to do files and langs with ObjectModel. We thought: "hurray, Symfony!!!, we know it, we like it, its simple!"" And then we polietly ask about examples.

And we get examples, and assurance, that they are Doctrine. But they were not. And this is main problem: it will be easy if you simple say: sorry it doesnt work, please try in 2022. We would know what there will be no help, because you simply have no knowleage about how it will work in future. Our problem is that we cannot get help, but got a lot of misleading information and examples.

Please decide yourself: "ObjectModel is not deprecated yet" (30-01-2020) and "The whole ObjectModel stack is being deprecated in 1.7 and will probably be removed in 1.8." (24-10-2018) is little misleading. (https://github.com/PrestaShop/PrestaShop/issues/11117)

It simple if you said that way: we will try, and give you sign if it work - no problem ;) And thank you for help and clarifing.

Hi @Bonobomagno

sorry I forgot about your request, we recently provided an example module that explains how to handle multi lang via Doctrine with PrestaShop. This is only one way to do it so consider this example as a proposition not a convention or a forced way to handle this feature.

https://github.com/PrestaShop/example-modules/tree/master/demodoctrine

This example is only usable with version >=1.7.7 because in previous versions the core entities were not accessible in front so defining a relationship with the Lang entity was only possible in the BO. Since this PR https://github.com/PrestaShop/PrestaShop/pull/19016 they are now accessible.

Also @kvokul indeed for now PrestaShop mainly relies on ObjectModel, we have very few Doctrine entities (like Lang) today because it's not the priority in the current roadmap. Yet we try to provide as many tools as possible for developers who want to use it (as I do ^^), so we try to improve its integration and use step by step. We don't integrate a Doctrine solution/plugin for now because it would be too early, and this example rely on the same database structure so that other developers are not confused.

Also relying on the same structure offers the possibility for developers to have an example on how they could create their own Doctrine entities that would match the existing legacy database structure, so if you really want to use doctrine for legacy models you can try and implement your own Doctrine layer for them.

Finally, I just finished a documentation about this topic that you can find in our devdoc at this address https://devdocs.prestashop.com/1.7/modules/concepts/doctrine/how-to-handle-multi-lang-doctrine-entity/ Feel free to read it, I hope it will be useful for you :)

With all this I think we can close this issue, that doesn't mean Doctrine will never be integrated more properly in PrestaShop core, it just means we won't integrate any multi-lang plugin or out of the box solution in it any soon.

If you have other questions though fell free to ask them, we can discuss on our community slack as well. And if the doc is lacking some information feel free to open an issue on its repository https://github.com/PrestaShop/docs

Was this page helpful?
0 / 5 - 0 ratings