# PrestaShop E-commerce

> PrestaShop with MySQL and Elasticsearch.

- Category: E-Commerce & Business
- Difficulty: intermediate
- Components: prestashop, mysql, elasticsearch
- Tags: prestashop, ecommerce, shop, php
- Source: https://docker.recipes/ecommerce/prestashop-stack

## Overview

PrestaShop is a powerful open-source e-commerce platform written in PHP that enables businesses to create and manage online stores with professional-grade features. Originally launched in 2007, PrestaShop has grown to power over 300,000 online shops worldwide, offering comprehensive product catalog management, order processing, payment integration, and customer relationship tools. The platform provides extensive customization capabilities through themes and modules, supporting everything from small boutique stores to large enterprise e-commerce operations with multi-store and multi-language functionality.

This stack combines PrestaShop with MySQL 8.0 for robust transactional data storage and Elasticsearch 7.17 for advanced search capabilities. MySQL handles all e-commerce data including products, customers, orders, and inventory with ACID compliance ensuring data integrity during high-volume transactions. Elasticsearch enhances the shopping experience by providing lightning-fast product search with relevance scoring, faceted navigation, and auto-complete suggestions that significantly improve conversion rates compared to basic SQL-based search.

This configuration is ideal for medium to large e-commerce businesses that need professional search functionality and can handle the additional complexity of managing Elasticsearch alongside their traditional database. Store owners who prioritize customer experience through fast, accurate product discovery will benefit most from this setup, as the Elasticsearch integration can dramatically improve search performance and provide analytics insights into customer search behavior.

## Features

- Auto-installation PrestaShop setup with configurable admin panel access through custom folder naming
- MySQL 8.0 with InnoDB storage engine providing ACID compliance for order processing and inventory management
- Elasticsearch full-text search with relevance scoring and faceted navigation for product catalogs
- PrestaShop's built-in multi-store management allowing multiple shops from single installation
- Advanced product catalog features including variants, combinations, and stock management
- Integrated payment gateway support for major providers like PayPal, Stripe, and regional processors
- MySQL Group Replication compatibility for high-availability e-commerce deployments
- Elasticsearch aggregations for sales analytics and customer behavior insights

## Use cases

- Fashion retailers needing advanced search with color, size, and brand filtering capabilities
- Electronics stores requiring detailed product specifications search and comparison features
- Multi-brand marketplaces managing thousands of products across different categories
- B2B wholesale platforms with complex pricing tiers and customer-specific catalogs
- International e-commerce sites leveraging multi-language and multi-currency support
- Growing online stores migrating from basic platforms to enterprise-grade search functionality
- Dropshipping businesses managing large product catalogs from multiple suppliers

## Prerequisites

- Minimum 4GB RAM (2GB for Elasticsearch, 1GB for MySQL, 1GB for PrestaShop and system overhead)
- Docker and Docker Compose installed with at least 10GB available disk space
- Port 8080 available for PrestaShop web interface access
- Basic understanding of e-commerce concepts and PrestaShop administration
- Environment variables configured: DB_USER, DB_PASSWORD, DB_ROOT_PASSWORD, ADMIN_EMAIL, ADMIN_PASSWORD
- SSL certificate and reverse proxy knowledge for production deployments

## docker-compose.yml

```yaml
services:
  prestashop:
    image: prestashop/prestashop:latest
    container_name: prestashop
    restart: unless-stopped
    ports:
      - "${PS_PORT:-8080}:80"
    environment:
      - DB_SERVER=ps-mysql
      - DB_NAME=prestashop
      - DB_USER=${DB_USER}
      - DB_PASSWD=${DB_PASSWORD}
      - PS_INSTALL_AUTO=1
      - PS_DOMAIN=localhost:${PS_PORT:-8080}
      - PS_FOLDER_ADMIN=admin_secure
      - ADMIN_MAIL=${ADMIN_EMAIL}
      - ADMIN_PASSWD=${ADMIN_PASSWORD}
    volumes:
      - prestashop_data:/var/www/html
    depends_on:
      - ps-mysql

  ps-mysql:
    image: mysql:8.0
    container_name: ps-mysql
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=prestashop
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASSWORD}
    volumes:
      - mysql_data:/var/lib/mysql

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
    container_name: ps-elasticsearch
    restart: unless-stopped
    environment:
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    volumes:
      - es_data:/usr/share/elasticsearch/data

volumes:
  prestashop_data:
  mysql_data:
  es_data:
```

## .env

```bash
# PrestaShop
PS_PORT=8080
DB_USER=prestashop
DB_PASSWORD=ps_password
DB_ROOT_PASSWORD=root_password
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=admin_password
```

## Usage notes

- Docs: https://devdocs.prestashop-project.org/
- Store at http://localhost:8080, admin at /admin_secure
- Delete /install folder after setup (security requirement)
- Enable Elasticsearch in Shop Parameters > Search for better performance
- Install modules from PrestaShop Addons marketplace
- Built-in multi-store and multi-language support

## Troubleshooting

- PrestaShop shows database connection error: Verify ps-mysql container is running and DB_* environment variables match MySQL configuration
- Elasticsearch container exits with OutOfMemoryError: Increase Docker memory limits or reduce ES_JAVA_OPTS heap size from 256m
- PrestaShop installation hangs at database setup: Check MySQL container logs for initialization completion before starting PrestaShop
- Search functionality not working after Elasticsearch setup: Enable Elasticsearch module in PrestaShop admin under Shop Parameters > Search
- Admin panel returns 404 error: Verify PS_FOLDER_ADMIN environment variable matches the actual admin folder name
- Product images not displaying properly: Ensure prestashop_data volume has proper write permissions and sufficient disk space

