adeoweb/custom-entity-bundle
Symfony bundle for Akeneo PIM that streamlines creating and managing reference data (custom entities) and related UI views. Install via Composer, register routes and bundle, and optionally add a quick export job for CSV reference data.
Installation
composer require adeoweb/custom-entity-bundle:"5.0.*"
Ensure your Akeneo PIM version matches the requirements table.
Enable the Bundle
Add to config/bundles.php:
return [
// ...
Adeoweb\CustomEntityBundle\AdeowebCustomEntityBundle::class => ['all' => true],
];
First Use Case: Create a Custom Entity
Define a YAML config file (e.g., config/akeneo/custom_entity/my_custom_entity.yml):
akeneo_custom_entity:
entities:
my_custom_entity:
label: "My Custom Entity"
class: "App\Entity\CustomEntity"
form:
fields:
- { property: "name", type: "text", label: "Name" }
- { property: "description", type: "textarea", label: "Description" }
Clear Cache
php bin/console cache:clear
Verify in Akeneo UI Navigate to Settings > Custom Entities to see your new entity.
Define Entity Structure Use YAML/XML config to define:
text, select, date).ProductCategory entity:
akeneo_custom_entity:
entities:
product_category:
label: "Product Category"
class: "App\Entity\ProductCategory"
form:
fields:
- { property: "code", type: "text", label: "Category Code" }
- { property: "parent", type: "entity", label: "Parent Category", entity: "product_category" }
Integrate with Business Logic
product.save) to sync custom entities:
// src/EventListener/ProductListener.php
use Adeoweb\CustomEntityBundle\Event\CustomEntityEvent;
class ProductListener {
public function onProductSave(CustomEntityEvent $event) {
$product = $event->getProduct();
$category = $product->getCategory();
// Save/Update custom entity logic here
}
}
services.yml:
services:
App\EventListener\ProductListener:
tags:
- { name: kernel.event_listener, event: product.save, method: onProductSave }
API/Grid Integration Extend Akeneo’s API/Grid to include custom entity data:
src/Akeneo/Pim/Enrichment/Controller/Api/ReadController.php to add custom fields to API responses.src/Akeneo/Pim/Enrichment/Controller/Admin/Grid/FieldProvider for grid columns.Validation Rules Add validation via config:
akeneo_custom_entity:
entities:
product_category:
validation:
- { property: "code", constraints: { NotBlank: {}, Length: { max: 50 } } }
Version Mismatch
composer why-not to debug.Cache Dependencies
php bin/console akeneo:custom-entity:dump && php bin/console cache:clear
Entity Class Autoloading
App\Entity\CustomEntity exists in src/Entity/).Field Type Limitations
akeneo_pim_enrichment_form_field_select) may not render.text, textarea, select, date, entity). Extend via custom form types if needed.Database Schema
php bin/console doctrine:migrations:diff && php bin/console doctrine:migrations:migrate
APP_DEBUG=true) and check var/log/dev.log for Adeoweb\CustomEntityBundle entries.akeneo:custom-entity:dump command to verify loaded configurations:
php bin/console akeneo:custom-entity:dump
Custom Form Types
Extend Adeoweb\CustomEntityBundle\Form\Type\CustomEntityType to add new field types:
// src/Form/Type/CustomColorType.php
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class CustomColorType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('color', ColorType::class);
}
}
Register in services.yml and reference in your YAML config:
form:
fields:
- { property: "color", type: "custom_color", label: "Color" }
Custom Actions Add buttons/actions to the custom entity grid via JavaScript:
// web/js/custom-entity-actions.js
require(['underscore', 'jquery', 'akeneo-grid-selector'], function(_, $, gridSelector) {
gridSelector.addAction('my_custom_entity', {
name: 'export',
label: 'Export',
action: function() { /* Logic */ }
});
});
API Filters Extend Akeneo’s API filters to support custom entity queries:
// src/Akeneo/Pim/Enrichment/API/Filter/CustomEntityFilter.php
use Akeneo\Tool\API\Rest\AbstractFilter;
class CustomEntityFilter extends AbstractFilter {
public function apply(QueryBuilder $qb, array $parameters) {
// Add custom WHERE clauses
}
}
How can I help you explore Laravel packages today?