Hi there,

I have installed the commerce_demo module in three seperate ways and only the last was succesfull. Perhaps a small manual can be added to the frontpage to prevent others from having the same issue.

Method 1: Installing with commerce_base installation profile
This does not work as both the installation profile and demo module provide some pieces of configuration (menu blocks, search index, etc) that collide when installing both.

Method 2: Installing with minimal installation profile (d8 core)
This seems to install but doesn't create any products.

Method 3: Installing with the standard installation profile (d8 core)
Installation succeeded and i have products to view.

I'll give you some text to copy, edit, ignore:

Installation instructions
The commerce demo module needs to be installed with at least the standard drupal core installation profile. Using the minimal profile will not result in a fully operational demo store. Using any other installation profile that is based on Drupal core standard should work but can collide with existing configuration.

Installing the module after a clean Drupal core installation can be a demanding operation for your laptop, desktop, webserver. It is recommended to expand PHP's minimum execution time to at least 300 seconds.

Comments

ericmulder1980 created an issue. See original summary.

bojanz’s picture

We generally install commerce_demo as a part of the whole parent distro, the Composer demo-project:
https://github.com/drupalcommerce/demo-project

Other installation methods will be perfected over time. We'll probably need separate issues for commerce_base and minimal. I am surprised that commerce_base doesn't work, since it's mostly a clone of standard with the Commerce modules added to the install list.

mglaman’s picture

Assigned: Unassigned » mglaman

Exploring this a bit.

The profile in the Composer template provides block placement and sample pages. This is the glue which allows proper placement of blocks for the demo.

It discussion with bojanz, it would make sense to just place Belgrade specific configuration into the config/optional directory, removing the need to use the template. However, that does not help with Bartik or other future themes the demo could support "out of the box" (or themes built for the demo.)

An idea would be a "theme installer service" to dynamically place blocks in proper regions for more custom themes. Instead of maintaining hundreds of optional config. This would invoke on commerce_demo_modules_installed when the module itself is installed, or whenever a theme is installed.

EDIT: This is blocked on #2988636: Automatically swap out the default cart block plugin definition's class.. The Belgrade cart block config targets that plugin. Instead it should target the one provided by Commerce itself.

mglaman’s picture

Status: Active » Needs review
StatusFileSize
new5.89 KB

This is an initial patch with some basic testing. Whenever the module is installed, blocks are set up for the active theme. Whenever a theme is installed, its blocks are set up and placed.

I need to test with a basic installation and changing themes on an active site.

mglaman’s picture

StatusFileSize
new6.5 KB

Handles changing a theme when the site is installed. Note

      // When changing themes, the `block_themes_installed` hook runs first,
      // and invokes block_theme_initialize. This caused blocks from the
      // previous theme to carry over. We ensure, here, their placement in the
      // event the block was moved to the "default" region.
mglaman’s picture

Status: Needs review » Needs work

I tested Method 3 as mentioned. It works as documented, but no blocks placed.

mglaman’s picture

:) because the active theme is "seven", I need to check $default_theme = \Drupal::config('system.theme')->get('default');

mglaman’s picture

Status: Needs work » Needs review
StatusFileSize
new6.47 KB

Fixes scenario 3. Working on 2 (minimal install)

mglaman’s picture

While testing, I wasn't able to reproduce the issues on the minimal install.

But we should also document:

Installing the module after a clean Drupal core installation can be a demanding operation for your laptop, desktop, webserver. It is recommended to expand PHP's minimum execution time to at least 300 seconds.
mglaman’s picture

Title: Advised installation method » Ensure components for the demo are available after installation
Component: Documentation » Code
Assigned: mglaman » Unassigned
StatusFileSize
new7.33 KB

Updated patch after discussing w/ bojanz.

Also retitling. The main focus is ensuring parts of the demo exist regardless if it is installed through our demo template or not.

mglaman’s picture

Status: Needs review » Needs work
  1. +++ b/commerce_demo.module
    @@ -59,6 +59,20 @@ function commerce_demo_modules_installed($modules) {
    +    $theme_installer = \Drupal::getContainer()->get('commerce_demo.theme_handler');
    ...
    +    $theme_installer->placeBlocks($default_theme);
    ...
    +  $theme_installer = \Drupal::getContainer()->get('commerce_demo.theme_handler');
    ...
    +    $theme_installer->placeBlocks($theme);
    

    theme_handler

  2. +++ b/src/ThemeHandler.php
    @@ -0,0 +1,162 @@
    +    // The commerce_base profile already provides a shopping cart block.
    +    if ($this->blockStorage->load('shopping_cart')) {
    +      unset($data['shopping_cart']);
    +    }
    +    else {
    +      $data['shopping_cart']['region'] = 'header';
    +      $data['shopping_cart']['weight'] = NULL;
    +    }
    

    We should account for this in the main block definitions when placing blocks.
    It can be removed, we account for existing blocks.

mglaman’s picture

Status: Needs work » Needs review
StatusFileSize
new7.3 KB

New patch. Also ensures block is enabled.

  • mglaman committed d14688c on 8.x-1.x
    Issue #2986537 by mglaman, bojanz: Ensure components for the demo are...
mglaman’s picture

Status: Needs review » Fixed

  • mglaman committed f4917fd on 8.x-1.x
    Issue #2986537 follow up: Fix visibility settings.
    
bojanz’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.