You will find all custom files in the doc/example
directory.
Feel free to create a symbolic link to these resources in your src directory and add the bundle in your app/AppKernel.php
file.
We need to override the PIM product value to add the to add the new textCollection backend type.
Firstly, we will define the new ProductValue
class in our custom AppBundle. To ease the integration,
the extension provides a Trait to avoid copy-paste.
The resulting ProductValue should look like the example: AppBundle/Model/ProductValue.php
We then need to override the Doctrine namespace to use this new definition.
In app/config/config.yml
, modify the configuration of the akeneo_storage_utils
section:
akeneo_storage_utils:
mapping_overrides:
-
original: Pim\Component\Catalog\Model\ProductValue
override: Acme\Bundle\AppBundle\Model\ProductValue
Now that the namespace is redefined, we will configure this model to add our new field.
Create the ProductValue
overridden configuration in AppBundle/Resources/config/model/doctrine/ProductValue.orm.yml:
Acme\Bundle\AppBundle\Model\ProductValue:
type: entity
table: pim_catalog_product_value
changeTrackingPolicy: DEFERRED_EXPLICIT
indexes:
value_idx:
columns:
- attribute_id
- locale_code
- scope_code
varchar_idx:
columns:
- value_string
integer_idx:
columns:
- value_integer
fields:
textCollection:
type: json_array
nullable: true
column: value_text_collection
We will apply all these modifications to the database schema. In a development environment, you can use the
doctrine command app/console doctrine:schema:update --dump-sql
to check the modifications,
and then app/console doctrine:schema:update --force
to apply them. n a production environment,
you should rely on migrations or other safer migrations scripts.
Lastly, we need to clear the cache and regen assets to access all new classes and JS files:
app/console cache:clear; app/console pim:installer:assets
(with --env=prod
for a prod environment).