PrestaShop 9.2

PrestaShop 9.2 Extra Properties: Revolutionizing Custom Fields Without Overrides

For years, customizing PrestaShop entities like products, customers, or categories often meant grappling with complex overrides. While powerful, overrides could introduce maintenance headaches, complicate upgrades, and increase technical debt. The PrestaShop community has long sought a more elegant solution for extending core functionalities. With the release of PrestaShop 9.2, that solution has arrived: Extra Properties.

At Migrate My Shop, we understand the critical role customization plays in building a unique and efficient online store. This groundbreaking feature promises to simplify development, streamline future upgrades, and make migrations smoother than ever before. Let's dive deep into what Extra Properties are, how they work, and why they're a game-changer for your PrestaShop store.

PrestaShop 9.2 Extra Properties configuration interface
PrestaShop 9.2 Extra Properties configuration interface

What are PrestaShop Extra Properties?

Extra Properties in PrestaShop 9.2 empower merchants and developers to add custom data fields to existing entities without writing a single override. Imagine needing a 'warranty note' for products, a 'preferred contact method' for customers, or a 'seasonal availability' flag for categories. Previously, this required custom database modifications and extensive code changes. Now, it's a configurable process directly within the PrestaShop back office.

Behind the scenes, each Extra Property you define becomes a new column in a dedicated value table for its respective entity. These value tables are joined one-to-one with the main entity table, ensuring data integrity and efficient retrieval. The definitions for all Extra Properties are centrally managed under Advanced Parameters > Extra Properties, providing a clear, organized overview of your custom fields, their types, scopes, and visibility settings.

The Power of Configuration: Creating an Extra Property

The process of creating a new Extra Property is intuitive, guided by a multi-tab form in the back office. Let's walk through the key steps:

  • Field Definition: This is where you lay the groundwork. You'll select the entity you wish to extend (e.g., 'product'), define the property name (which becomes the database column name, adhering to SQL naming conventions like warranty_note), and choose the field type. PrestaShop offers a rich selection of types, including Integer, Boolean, Text, Decimal number, Date, Rich text (HTML), JSON, or Choice list. It's crucial to note that JSON properties won't appear in grids, and HTML/JSON columns cannot have SQL default values.
  • Scope: The 'scope' determines how values are stored and accessed.
    • common: One value per entity (e.g., a single warranty note for a product).
    • lang: One value per language (useful for translatable fields, requiring an {entity}_lang table).
    • shop: One value per shop in a multistore environment (requiring an {entity}_shop table).
  • Visibility: The 'Display in front-office' option makes the value accessible to front-office presenters (themes, modules). The 'Required' flag only sets the HTML required attribute and the OpenAPI flag; server-side validation for non-empty values needs to be configured in the 'Validation' tab using a 'NotBlank' constraint.
  • Labels & Descriptions: Provide user-friendly labels and descriptions that will appear in the back office.
  • Validation: This tab allows you to apply Symfony constraints to ensure data integrity. For instance, adding a NotBlank constraint will prevent empty values from being saved.
  • Placement: A critical step! Saving a property definition doesn't automatically display it anywhere. You must explicitly opt-in for its appearance in Forms, Grids, and the Admin API. By clicking 'Add a form' and using the 'Form id' autocomplete, you can select where the field should appear. You can anchor it 'before', 'after', or use 'automatic' placement. For example, anchoring a field before header.name on the product form will place it prominently above the product name field.

Crucial Considerations and Best Practices

While Extra Properties offer immense flexibility, there are a few important points to keep in mind, as highlighted by early adopters:

  • Anchor Path Precision: Always use the suggested autocomplete paths for form placement. Incorrect paths can lead to HTTP 500 errors. If you encounter issues, clearing the cache and checking Symfony logs (with debug mode enabled) is essential.
  • Front-Office Display Requires Manual Integration: The 'Display in front-office' setting only makes the data available; it doesn't automatically render it. You'll need to modify your theme's Smarty templates (preferably in a child theme or module template) to display the value. For properties created in the back office, they live under the _core key:
    {if isset($product.extra_properties._core.warranty_note) && $product.extra_properties._core.warranty_note !== ''}
      {$product.extra_properties._core.warranty_note|escape:'htmlall':'UTF-8'}
    {/if}
    For module-registered properties, the module's technical name replaces _core.
  • HTML Escaping is Paramount: If you use the 'Rich text (HTML)' field type, always escape the output in your templates to prevent Cross-Site Scripting (XSS) vulnerabilities. The CleanHtml validation constraint is opt-in, not default.
  • Module Registration: Modules can programmatically register Extra Properties using Module::registerExtraProperty(). These properties appear in the back office as read-only for merchants, ensuring consistency and control for module developers.
Screenshot of PrestaShop 9.2 Extra Properties configuration page showing a list of defined properties.
Illustration: A screenshot mockup of the PrestaShop 9.2 back office, specifically the 'Extra Properties' configuration page showing a list of defined properties.

Limitations to Be Aware Of

While powerful, Extra Properties do have some current limitations:

  • Cart values are not automatically copied to the order at checkout.
  • Order grid columns may render empty, and their filters might not work.
  • Only migrated back-office forms and grids are extended; legacy pages are not.
  • As of the initial 9.2.0 beta, there was no file upload type.
  • A property cannot be limited to selected products, only to specific stores in a multistore setup.
  • No customer-facing input forms are provided; for shopper-filled fields (like text boxes or file uploads), the native PrestaShop 'Customization' feature is still the go-to.

The Impact on E-commerce Development and Migrations

For businesses considering a PrestaShop migration or upgrading their existing store, Extra Properties represent a significant leap forward:

  • Reduced Technical Debt: By eliminating the need for numerous overrides, stores become easier to maintain and less prone to conflicts during updates.
  • Simplified Upgrades: Upgrading to newer PrestaShop versions will be smoother, as custom data fields are integrated natively rather than through custom code that might break.
  • Cleaner Migrations: For clients migrating to PrestaShop from other platforms, or from older PrestaShop versions, custom data can now be integrated more cleanly and efficiently, reducing the complexity and cost of data mapping and custom development.
  • Enhanced Flexibility: Merchants gain unprecedented control over their data, allowing for more tailored product information, customer segmentation, and category management without developer intervention for every small change.

At Migrate My Shop, we see Extra Properties as a cornerstone of modern PrestaShop development. It empowers businesses to build more robust, flexible, and future-proof online stores. If you're planning a PrestaShop migration or looking to upgrade your existing store to leverage these powerful new features, our team of experts is here to guide you every step of the way. Embrace the future of PrestaShop customization!

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools