Skip to content

Generate FAQ for product page extended

csaeum/WSC_ShopwareFaq

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

RevinnersFaq Plugin

A Shopware 6 plugin for adding FAQ (Frequently Asked Questions) functionality to products.

Features

  • Product FAQ Integration - Add Q&A entries to any product
  • Frontend Display - Clean, simple FAQ display on product pages
  • Schema.org SEO - Automatic JSON-LD markup for Google rich snippets
  • Multi-language Support - Translations for FAQ titles
  • CLI Management - Easy command-line tools for FAQ management
  • Position Ordering - Control the order of FAQ entries
  • Active/Inactive - Show/hide FAQ entries as needed

Installation

  1. Copy the plugin to your Shopware 6 installation:

    custom/plugins/RevinnersFaq/
  2. Install and activate the plugin:

    bin/console plugin:refresh
    bin/console plugin:install --activate RevinnersFaq
    bin/console cache:clear
  3. Run database migrations (happens automatically during installation)

CLI Commands

The plugin provides convenient CLI commands for managing FAQ entries:

List FAQs for a Product

# List active FAQs for a product
bin/console revinners:faq:list SW10000

# List all FAQs (including inactive)
bin/console revinners:faq:list SW10000 --all

# Get JSON output
bin/console revinners:faq:list SW10000 --json

Add New FAQ

# Add FAQ with auto-position
bin/console revinners:faq:add SW10000 "Question text?" "Answer text"

# Add FAQ with specific position
bin/console revinners:faq:add SW10000 "Question?" "Answer" --position=1

# Add inactive FAQ
bin/console revinners:faq:add SW10000 "Question?" "Answer" --inactive

Update FAQ

# Update question only
bin/console revinners:faq:update 29bb2fc3 --question="New question?"

# Update answer
bin/console revinners:faq:update 29bb2fc3 --answer="New answer"

# Update position
bin/console revinners:faq:update 29bb2fc3 --position=5

# Set as active/inactive
bin/console revinners:faq:update 29bb2fc3 --active
bin/console revinners:faq:update 29bb2fc3 --inactive

# Update multiple fields at once
bin/console revinners:faq:update 29bb2fc3 --question="New Q?" --answer="New A" --position=1

Delete FAQ

# Delete with confirmation
bin/console revinners:faq:delete 29bb2fc3

# Force delete without confirmation
bin/console revinners:faq:delete 29bb2fc3 --force

Product Identification

Commands support multiple ways to identify products:

  • UUID: 0198f295d0c67b77b69e4b26c02c7ea5
  • Product Number: SW10000
  • GTIN/EAN: If set in product data

Database Structure

The plugin creates a revinners_product_faq table:

CREATE TABLE `revinners_product_faq` (
    `id` BINARY(16) NOT NULL,
    `product_id` BINARY(16) NOT NULL,
    `question` TEXT NOT NULL,
    `answer` TEXT NOT NULL,
    `position` INT(11) NOT NULL DEFAULT 0,
    `active` TINYINT(1) NOT NULL DEFAULT 1,
    `created_at` DATETIME(3) NOT NULL,
    `updated_at` DATETIME(3),
    PRIMARY KEY (`id`),
    CONSTRAINT `fk.revinners_product_faq.product_id` 
        FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) 
        ON DELETE CASCADE ON UPDATE CASCADE
);

Frontend Display

FAQs are automatically displayed on product detail pages in a simple format:

<div class="qa__section">
    <h3>Frequently Asked Questions</h3>
    
    <div class="qa__item">
        <div class="qa__answer">
            <div class="qa__question">Question text?</div>
            <p>Answer text.</p>
        </div>
    </div>
    <!-- More FAQ items -->
</div>

SEO Integration

The plugin automatically generates Schema.org JSON-LD markup:

{
    "@context": "https://schema.org",
    "@type": "FAQPage",
    "mainEntity": [
        {
            "@type": "Question",
            "name": "Question text?",
            "acceptedAnswer": {
                "@type": "Answer",
                "text": "Answer text."
            }
        }
    ]
}

Custom Styling

The plugin uses minimal CSS classes that you can customize:

.qa__section {
    // Main FAQ wrapper
}

.qa__item {
    // Individual FAQ item
}

.qa__question {
    // Question styling (bold by default)
}

.qa__answer p {
    // Answer paragraph styling
}

Manual Database Management

You can also manage FAQs directly via SQL:

-- Add FAQ entry
INSERT INTO revinners_product_faq 
(id, product_id, question, answer, position, active, created_at) 
VALUES 
(UNHEX(REPLACE(UUID(), '-', '')), 
 UNHEX('0198f295d0c67b77b69e4b26c02c7ea5'), 
 'Your question?', 
 'Your answer.', 
 1, 1, NOW());

Translations

The plugin supports multiple languages. Add translations in:

  • src/Resources/snippet/en_GB/storefront.en-GB.json
  • src/Resources/snippet/pl_PL/storefront.pl-PL.json

Current translation keys:

  • revinners-faq.product.faqTitle: FAQ section title

Development

Plugin Structure

src/
├── Command/                    # CLI commands
│   ├── FaqAddCommand.php
│   ├── FaqListCommand.php
│   ├── FaqDeleteCommand.php
│   └── FaqUpdateCommand.php
├── Core/Content/ProductFaq/    # Entity layer
│   ├── ProductFaqDefinition.php
│   ├── ProductFaqEntity.php
│   └── ProductFaqCollection.php
├── Extension/Content/Product/  # Product entity extension
│   └── ProductExtension.php
├── Migration/                  # Database migrations
│   └── Migration1724854800ProductFaq.php
├── Resources/
│   ├── config/services.xml     # Service definitions
│   ├── snippet/               # Translations
│   └── views/storefront/      # Twig templates
├── Twig/                      # Twig functions
│   └── FaqExtension.php
└── RevinnersFaq.php           # Main plugin class

Extending the Plugin

The plugin is designed to be easily extendable:

  • Custom FAQ Types: Extend the entity definition
  • Admin Interface: Create administration module
  • API Integration: Use existing repositories
  • Custom Display: Override Twig templates

Requirements

  • Shopware 6.7+
  • PHP 8.1+
  • MySQL 5.7+

License

MIT License

Author

Revinners sp. z o. o.

Support

For support and bug reports, please contact the development team or create an issue in the project repository.

About

Generate FAQ for product page extended

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 95.2%
  • Twig 3.2%
  • SCSS 1.6%