Da79 Posted September 14, 2022 Share Posted September 14, 2022 Hi ! I'm trying to create a module to add content on our cms pages. I use hookActionCmsPageFormBuilderModifier to add custom fields to cms pages back office form and hookActionAfterUpdateCmsPageFormHandler/hookActionAfterCreateCmsPageFormHandler to store my custom fields value in my database through a Repository. To save my data I get my repository : $cmsPageRepository = $this->get('foo.module.extendcmsform.repository.cms_extra_data_repository'); Declared in services.yml : services: _defaults: public: true foo.module.extendcmsform.repository.cms_extra_data_repository: class: Foo\Module\ExtendCmsForm\Repository\CmsPageExtraDataRepository factory: ['@doctrine.orm.entity_manager', getRepository] arguments: - Foo\Module\ExtendCmsForm\Entity\CmsExtraData Until now everything works fine. Then I'm trying to get my custom data and show it through a widget so I have implemented renderWidget and getWidgetVariables in my Module class that implements WidgetInterface. In the renderWidget I try to retrieve my repository using the same method has before : $cmsPageRepository = $this->get('foo.module.extendcmsform.repository.cms_extra_data_repository'); But I'm getting a ServiceNotFoundException when I try to reach my cms page. What am I doing wrong ? How can I retrieve then show my custom data in my cms pages ? Thank You ! Link to comment Share on other sites More sharing options...
Janett Posted September 15, 2022 Share Posted September 15, 2022 https://devdocs.prestashop-project.org/1.7/modules/concepts/services/#services-in-legacy-environment Link to comment Share on other sites More sharing options...
Da79 Posted September 16, 2022 Author Share Posted September 16, 2022 On 9/15/2022 at 10:20 AM, Janett said: https://devdocs.prestashop-project.org/1.7/modules/concepts/services/#services-in-legacy-environment Hi Janett, it works now ! It wasn't clear to me the controller can differ depending if the method is admin or front. Thank you ! 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