Git Product home page Git Product logo

example-modules's Introduction

Example modules

This repository hosts example modules built and maintained by PrestaShop. These modules demonstrate usecases useful for developers willing to customize the software.

Modules list

Module name Description Minimum version
api_module This example module demonstrates how to modify PrestaShop's new API. v9.0.0
demo_grid This module demonstrates how to use Grid in PrestaShop 1.7.7+ v1.7.7
democonsolecommand Example module showing how to implement a Symfony console command v1.7.7
democontrollertabs Demo Creating modern Controllers and associate Tabs to them v1.7.7
demodoctrine This module demonstrates how to use Doctrine entities in PrestaShop 1.7.7 and above v1.7.7
demoextendgrid This module demonstrates how to insert an additional row action to existing grid and how to register javascript in admin controller v1.7.7
demoextendsymfonyform1 Learn using identifiable object and grid hooks. v1.7.6
demoextendsymfonyform2 This module demonstrates how to insert an "upload image" input field inside the Symfony form managing "Edit a Supplier" page and how to use DoctrineORM to manage the database state of a custom object v1.7.7
demoextendsymfonyform3 This example demonstrates the usage of CQRS pattern and hooks v1.7.6
demoextendsymfonyform4 This example demonstrates the usage of CQRS pattern and hooks v9.0.0
demoextendtemplates This is example module explaining various extendability options of templates v8.0.0
demoformdataproviders This module illustrates FormDataProviderData and FormDataProviderDefaultData hooks v8.0.0
demojsrouting This module illustrates how to use Javascript Router component in a module v1.7.7
demomoduleroutes This module illustrates using the moduleRoutes hook in a module. v8.0.0
demomultistoreform This module demonstrates how to make your forms multistore compatible in your module, in a CRUD context. v1.7.8
demooldproductpagehooks This module illustrates the hooks on the old product page. v1.7.8
demooverrideobjectmodel Example module showing how to override an ObjectModel (in this case the manufacturer) and add a custom field in the database table. v1.7.7
demoproductextracontent Example module to add extra content to the product page on the front office v1.7.0
demoproductform This is an example module explaining various extendability options in product page form v8.1.0
demoproductform2 This is an example module explaining various extendability options in product page form v9.0.0
demosymfonyform This module demonstrates how to use existing PrestaShop Symfony form types inside a new page. v8.0.0
demosymfonyformsimple In this module, you will learn how to utilize Symfony form types to create configuration pages for your module. This module has been created by following a guide from the developer documentation. v8.0.0
demovieworderhooks This module was created in order to demonstrate how to use the new hooks introduced with the new "View an Order" back office page in PrestaShop 8.0.0 and below. v1.7.7
demowsextend This module adds a resource managed by ObjectModel to the WebService. v1.7.8
example_module_mailtheme Example module to add a Mail theme to PrestaShop. v1.7.6

example-modules's People

Contributors

0x346e3730 avatar atomiix avatar dependabot[bot] avatar devantoine avatar hlavtox avatar jevgenijvisockij avatar jolelievre avatar kpodemski avatar leemyongpakvn avatar louisauthie avatar ludovicus64 avatar m0rgan01 avatar marionf avatar matks avatar matthieu-rolland avatar mflasquin avatar micreas avatar nicosomb avatar nkoonen avatar oksydan avatar pierrerambaud avatar prestaedit avatar prestasafe avatar progi1984 avatar pululuk avatar tdavidsonas88 avatar thomasnares avatar tleon avatar touxten avatar zuk3975 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

example-modules's Issues

Module demoproductform and Prestashop 8.1.0

Hello,

I am trying to use the ActionProductFormBuilderModifier hook from the demoproductform module, but I don't see the "Demo custom field" field in the Description tab. I do see the new module tab in the Product page, but not the new field from the ActionProductFormBuilderModifier. The "New product page" feature is enabled.

Does someone know how to fix it? Is it a 8.1.0 issue?

Thank you

npm error while building in module

I have tried to create a modern module in Prestashop 1.7.7.3, it has a custom grid which displays correctly, all the data are there but the javascript based functions are not working.
The next thing I did was including the necessary js files like in the example module called demodoctirne but when I tried to use the npm run build (or dev) commands I have run into an error message:

ERROR in /var/www/html/admin-dev/themes/new-theme/js/components/grid/extension/bulk-action-checkbox-extension.js
Module build failed: Error: Couldn't find preset "env" relative to directory

Of course I used npm install, a bundle file was created and it is included in the template file, in the browser console I get a similar error message when the page with the grid loads:

Uncaught Error: Module build failed: Error: Couldn't find preset "env" relative to directory

I customized the common.js and the index.js which looks like this:

var $ = window.$;
import Grid from '@components/grid/grid';
import ReloadListActionExtension from '@components/grid/extension/reload-list-extension';
import ExportToSqlManagerExtension from '@components/grid/extension/export-to-sql-manager-extension';
import FiltersResetExtension from '@components/grid/extension/filters-reset-extension';
import SortingExtension from '@components/grid/extension/sorting-extension';
import LinkRowActionExtension from '@components/grid/extension/link-row-action-extension';
import SubmitGridExtension from '@components/grid/extension/submit-grid-action-extension';
import SubmitBulkExtension from '@components/grid/extension/submit-bulk-action-extension';
import BulkActionCheckboxExtension from '@components/grid/extension/bulk-action-checkbox-extension';
import SubmitRowActionExtension from '@components/grid/extension/action/row/submit-row-action-extension';


$(() => {
  const customGrid = new Grid('customGrid');

  customGrid.addExtension(new ReloadListActionExtension());
  customGrid.addExtension(new ExportToSqlManagerExtension());
  customGrid.addExtension(new FiltersResetExtension());
  customGrid.addExtension(new SortingExtension());
  customGrid.addExtension(new LinkRowActionExtension());
  customGrid.addExtension(new SubmitGridExtension());
  customGrid.addExtension(new SubmitBulkExtension());
  customGrid.addExtension(new BulkActionCheckboxExtension());
  customGrid.addExtension(new SubmitRowActionExtension());
});

This is the part in the common.js i changed:

module.exports = {
  externals: {
    jquery: 'jQuery',
  },
  entry: {
    customGrid: './customGrid',
  },
  output: {
    path: path.resolve(__dirname, '../../views/js'),
    filename: '[name].bundle.js',
    libraryTarget: 'window',
    library: '[name]',
  },
  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      '@components': psComponentsDir,
    },
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        include: path.resolve(__dirname, '../customGrid'),
        use: [{
          loader: 'babel-loader',
          options: {
            presets: [
              ['es2015', {modules: false}],
            ],
          },
        }],
      },
      {
        test: /\.js$/,
        include: psJsDir,
        use: [{
          loader: 'babel-loader',
          options: {
            presets: [
              ['es2015', {modules: false}],
            ],
          },
        }],
      },

Override AdminController.php and AdminOrdersController.php

Hi guys, @matks ,

Hope you are all well !

I am working on manticoresearch module for prestashop and I would like to override how the getlist function generate tables in the admin panel for orders, customers, products.

Since I am using the version 1.7.7.0, and legacy overrides are not working, what is the process now for overriding these classes in a non intrusive way ?

Ps. I have read the documentation but still confused on how to do that.

Any example would be just awesome. :-)

Cheers,
Luc Michalski

[Demo Doctrine module] Demo doctrine module crashes when using 2 languages in BO and a new quote is created but one language field is not filled in.

Describe the bug

Demo doctrine module crashes when 2 languages are enabled in BO and a new quote is created but one language field is not filled in.

Expected behavior

Demo doctrine module should not crash when 2 languages are enabled in BO and a new quote is created but one language field is not filled in.

It should either warn user that both language fields must be filled in, or support an empty field for one language.

Capture d’écran 2021-06-14 à 10 20 42

Steps to Reproduce

Steps to reproduce the behavior:

  1. Install demodoctrine module v1.0.0
  2. Make sure your shop has 2 languages enabled in BO
  3. Click on 'configure' to go on administration page of demodoctrine module
  4. Click 'Add a new quote'
  5. Fill in "author name"
  6. Fill in "Content" for one language, leave the other language empty for "Content"
  7. Submit, see Type Error

Screenshots

Capture d’écran 2021-06-14 à 10 20 33

Additional information

  • PrestaShop version: 1.7.8.x
  • PHP version: 7.4

Use CI

We should plug-in Travis to run what tests we have 😄 demonstrating how to plug a module to CI

Homogenize example modules

Multiple items should be homogenized in example modules to make it easier for developers to navigate them.

  • Module naming
  • Namespace naming
  • README
  • Composer configuration (remember it needs "prepend-autoloader": false)
  • Logo
  • Folder structure
  • License headers

add a screenshot for each examples

Hi @matks ,

Hope you are all well !

I was looking for an example module for extending the product form in prestashop and just said to myself that it would have been awesome to have a small screenshot per example in each READMEs ^^

Thanks for any insights or inputs on this thought.

Cheers,
Luc Michalski

Webpack build issues

I've only tested this on 2 of the demo modules so far, demo_grid and demodoctrine.
When you try to compile the webpack assets for the modules, they all seem to fail.

Could the modules be updated so that they correctly compile under Prestashop 8? And providing step by step details on how to do so would also be very helpful for others

Make example modules works with Prestashop 8.0

For the moment the modules do not work on prestashop 8. Most often when accessing the configuration route of the module, for example :

image

  • demo_grid
  • democonsolecommand
  • democontrollertabs
  • demodoctrine
  • demoextendgrid
  • demoextendsymfonyform1
  • demoextendsymfonyform2
  • demoextendsymfonyform3
  • demojsrouting
  • demomultistoreform
  • demooverrideobjectmodel
  • demoproductform
  • demosymfonyform
  • demovieworderhooks
  • #154

The demoproductform module does not work in 8.0.0

The module can be installed and does not throw any errors but does not add any new fields to the product form. I am trying to learn module development and this just puzzled me especially when the version inside the module is set to min 8.0.0.

It seems like the hookActionProductFormBuilderModifier is no longer being called. I tried to throw an error on the first line of that function and it does not break anything in the product form when it's loaded.

Confusion about Demo Symfony Form module 1

There is confusion about Demo Symfony Form module 1 because the module demonstrates 2 things:

  • how to use a CQRS in a module
  • how to use hooks to add new field to a Symfony form

Some community developers think that the two must be together although actually you can choose to use CQRS or not to add new field to a Symfony form.

In order to clear the confusion I will

  • Modify demoextendsymfonyform1 to drop the use of CQRS - see #35
  • Copy demoextendsymfonyform1 as demoextendsymfonyform3 where CQRS will be used - #33

Module tabs

Hi

The demo modules have been extremely useful in adapting modules to use modern controllers and Ux.

I wonder if I could request a new demo module which demonstrates how to implement tabs in the configuration of a module using new Symfony controllers and twig templates.

The attached screnshot shows the kind of tabs I am referring to.

screenshot

How add new option to caching_system

public function hookActionPerformancePageForm(&$params)
    {
        /* @var $formBuilder \Symfony\Component\Form\FormBuilder */
        $formBuilder = $params['form_builder'];

        $cacheForm = $formBuilder->get('caching');
        $cachingSystemForm = $cacheForm->get('caching_system');

        $options = $cachingSystemForm->getOption('choices');
        $options['redis'] = 'redis';
        $cachingSystemForm->add('4', \Symfony\Component\Form\Extension\Core\Type\RadioType::class, [
            'value' => 'CacheRedis',
            'label' => $this->getLabel(),
            'disabled' => $this->getDisabled()
        ]);
//        dump($cachingSystemForm);
//        die();

    }

i can see the redis options.but after saved,the parameters.php 'ps_caching' not change

More Symfony services examples

We need more examples:

  • how to point original route to a different controller
  • how to override a service
  • maybe some other valid examples of how to work with service container extensibility features directly from the modules

Test with PrestaShop 8.1

All modules present in this repository have to be tested against PrestaShop 8.1.

  • demo_grid
  • democonsolecommand
  • democontrollertabs
  • demodoctrine
  • demoextendgrid
  • demoextendsymfonyform1
  • demoextendsymfonyform2
  • demoextendsymfonyform3
  • demoextendtemplates
  • demojsrouting
  • demomoduleroutes
  • demomultistoreform
  • demooldproductpagehooks
  • demooverrideobjectmodel
  • demoproductform
  • demosymfonyform
  • demovieworderhooks
  • demowsextend

demosymfonyform

As Prestashop charges forward with leveraging more of Symfony code, Prestashop developers like myself are keen to adopt this approach as much as possible and these demo modules provide a encouraging start.

In relation to the demosymfony module, it would be great if the following could be demonstrated:

  • Saving to a object model (rather than configuration)
  • Rendering and processing a symfony form in the displayAdminProductsExtra hook

Additionally, it seems there is significant boilerplate code required to setup forms in a module (services, classes, and even javascript code). Are there any command line utilities available which could help developers generate a simple form?

ClassNotFoundException ; Attempted to load class LegacyLayout from the global namespace

When I try to create a new quote in demodoctrine I get the following error:

Attempted to load class "LegacyLayout" from the global namespace.
Did you forget a "use" statement?

CRITICAL20:22:59 | php | Class 'LegacyLayout' not found
CRITICAL20:22:59 | request | Uncaught PHP Exception Symfony\Component\Debug\Exception\ClassNotFoundException: "Attempted to load class "LegacyLayout" from the global namespace. Did you forget a "use" statement?" at /var/www/prestashop/classes/controller/AdminController.php line 3674

Thanks a lot.

Demo View Order Hooks : phpstan

We started usage of phpstan into Demo View Order Hooks module however it is not complete.

  • make it complete
  • make it run by Travis
  • write about it into the README to promote/demonstrate phpstan usage

FormattedTextareaType should use TranslateType

In this documentation page, it is written that TranslateType should be used instead of TranslatableType with a FormattedTextareaType field.

If you wish to use FormattedTextareaType as type, your base type must be TranslateType instead of TranslatableType. Do not forget to add the option hideTabs at true if you want to display the languages list above the WYSIWYG.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.