basilicom/multi-domain-bundle

This Bundle provides Multi-Domain features for Pimcore.

dev-master 2020-11-25 16:11 UTC

This package is auto-updated.

Last update: 2024-10-26 01:04:33 UTC


README

Adds functionality to work with multi-dimensional domain specific attributes in Pimcore objects.

On a technical level, it allows an object variant to have multiple parents for inheritance. This is achieved by dynamically re-writing the variant inheritance parent lookup by injecting domain specific variant siblings instead.

The order of domain selection determines the domain variant precedence.

Furthermore, variants can have domain variants as childs, which are able to override already specified field values in regular variants (see demo data below, "Amazon" domain variant for "Size S").

This bundle contains an AdminStyle extension, in order to change the variant icon to a "mind-map" icon and provide special quicktips on hover, too.

Glossary:

  • Domain Variant - an object variant, where the domain field is NOT empty
  • Domain Sibling - a domain variant next to a regular variant object, providing domain specific value inheritance fallback
  • Domain Child - an domain variant as child of a regular variant object, overriding regular variant values

Hint: If Pimcore debug mode is enabled, a lot of messages are logged!

License

GPLv3 - see: gpl-3.0.txt

Requirements

  • Pimcore >= 6.0.0

Installation

  1. Install the bundle using composer composer require basilicom/multi-domain-bundle dev-master.
  2. Execute bin/console pimcore:bundle:enable BasilicomMultiDomainBundle

Configuration

  • Add a field named domain to the class to enable multi domain capabilities for. This can be any field type, which get() method resolves into a string. Usually, choose a select field.
  • Configure the class to use Basilicom\MultiDomainBundle\Model\DataObject as "Parent PHP Class".

Example: alt text

Usage

Use objects and variants (variant hierarchies) as usually. Add variants as childs to an object or a variant and set the domain field to some value (not null) in order to configure a domain specific variant.

Get domain specific object value as usually, but select any number of domains beforehand:

use Basilicom\MultiDomainBundle\Service\Domain;

$object = \Pimcore\Model\DataObject\AbstractObject::getByPath('/my-object');

// select two domain contexts, first to contain a value override wins!
Domain::select(['Country US', 'Marketplace eBay']);

$fieldValue = $object->getMyFieldName();

// reset selected domain; normal pimcore behaviour:
Domain::clear(); 

If you retrieve an object and you want to know if it is a domain variant, just use: $myObject->isDomainVariant()

Samples

Given the following object/variant setup:

alt text

With object and/or variants set up like:

alt text

alt text

alt text

alt text

alt text

alt text

alt text

alt text

You get the following data for the various domain selections:

Limitations

  • use at own risk, intensive testing suggested!
  • needs more cleanup