Prestashop: Installing module dependency from theme fails while normal install is ok

Created on 26 Feb 2019  路  9Comments  路  Source: PrestaShop/PrestaShop

I have a module added as a dependency of my theme that I am developing.

Like this in the yml:
dependencies:
modules:
- myModule

If I try to install the theme, it says it is not valid for PS1.7. If I upload the theme however, and press Use this theme, it fails with another more specific error complaining that my module is not ok.

The issue is that installing the module on its own through the module manager works just fine and then I can go back and select the theme with no problems.

I think there might be something not working correctly with the dependencies in the yml file for themes.

I guess a simple way to reproduce would be to make a copy of classic, add a dependency to a module that is not installed yet and then try to use that theme.

1.7.4.4 1.7.5.0 1.7.5.1 1.7.6.0 BO Bug Minor Modules & Themes Theme & logo To Do

Most helpful comment

Ok, cool. Then I leave it to you to see if it can be fixed. There is a workaround of course installing the module manually but I think this is important for theme developers so that a theme with custom modules can be installed without doing tricks to make it work.

All 9 comments

Hi @johanlantz,

I made a copy for the Classic theme. "test".
In the file /themes/test/config/theme.yml, I added - ps_bestsellers in the display home section


      displayHome:
        - ps_imageslider
        - ps_featuredproducts
        - ps_banner
        - ps_customtext
    - ps_bestsellers

When I try to navigate to the BO => Design => Theme & LOgo => I have exception
image

Which is a normal behavior => is it?
Thanks!

That was not really the case I was aiming for. I will try to have time to investigate more but my scenario is this, hope I can explain it ok.

  • I am developing a child theme of classic.
  • With this theme, I want to pack a custom module, so I do two things:

    1. I put this module in the dependencies folder of the theme

    2. I add the name of the module under dependencies in the theme.yml file.

Now, when I try to install the theme it fails, complaining that the module in the dependencies folder is not valid. However, If I simply put the module in a zip file and install it through the Module Manager it works just fine.

Due to this I suspect that something might be wrong with how module dependencies are working when installing a theme.

I can work around this by installing the module manually and then the theme installs fine since it find s the module as installed already and does not have to pick it up from the dependencies folder of the theme.

Hi @johanlantz,

Thanks for these clarifications.
I did not manage to reproduce the issue with PS1.7.5.1.
https://drive.google.com/file/d/1yKqiWJiFklXzmouSlx_YAqdkliH-xduF/view
I created a child theme with

  1. folder dependencies which contains the module ps_bestsellers
  2. In the file /mythemes/config/theme.yml, I added this code
dependencies:
  modules:
    - ps_bestsellers

When I try to use this theme => OK.
I tried with this theme
mythem.zip
Thanks to check & feedback.

Thanks for the quick feedback. I will try tonight again.

Meanwhile, can you please make sure you test with a module that is not installed nor available in the marketplace. An empty module that does nothing should be just fine. As I mentioned, if the module is already installed or available in the shop, then the problem did not happen.

@johanlantz, thanks!
In fact, when I try to add a new theme that includes specific modules
The theme is well used.
I attached a video record.
https://drive.google.com/file/d/1-gcNjbJ5pHjtmUPZRZcZjCAX4AxJs55V/view
Thanks!

Hi

I still think there is a bug here.

I can reproduce using a minimal example:

  1. Create an empty child theme from classic.
  2. Create an empty module using the Prestashop module generator.
  3. Put the module in the dependencies folder of the child theme.
  4. Add the dependency in config.yml
  5. Add the hook in config.yml for the custom module.

Now, try to install this theme from the Backoffice and it fails with the error:
"Cannot install module testmodule. The module is invalid and cannot be loaded."

The module however installs fine if you install it on its own and not through the theme.

I attach the minimal example with the child theme being identical to classic, only the custom module is provided and this module does nothing, its just an empty shell generated by the Prestashop module generator.
atheme.zip

It was not clear to me if the module in dependencies should be unpacked or zipped, I tried both options but they gave the same error.

@johanlantz, Thanks for your feedback.
Yes, I tried with a child theme which has a custom module, when I try to install it, I have the same error
"Cannot install module mymodule. The module is invalid and cannot be loaded."
I tried with this child theme
mythem.zip
checked with PS1.7.4.4 & PS1.7.5.1 & PS1.7.5.0 => same issue.
I鈥檒l add this to the debug roadmap so that it鈥檚 fixed. If you have already fixed it on your end or if you think you can do it, please do send us a pull request!
Thanks!

Ok, cool. Then I leave it to you to see if it can be fixed. There is a workaround of course installing the module manually but I think this is important for theme developers so that a theme with custom modules can be installed without doing tricks to make it work.

With 1.7.6.0, when uploading mythem.zip I have the error below

capture d'茅cran_1656

Was this page helpful?
0 / 5 - 0 ratings