Install Dependencies Run:
composer require akeneo/cnet-connector:2.0.*
composer require akeneo-labs/custom-entity-bundle:2.*
composer require akeneo/extended-attribute-type:2.0.*
Enable Bundles
Add to app/AppKernel.php:
new Pim\Bundle\CustomEntityBundle\PimCustomEntityBundle(),
new Pim\Bundle\ExtendedAttributeTypeBundle\PimExtendedAttributeTypeBundle(),
new Pim\Bundle\CnetConnectorBundle\PimCnetConnectorBundle(),
Configure Brand Reference Data
Update app/config/config.yml:
pim_reference_data:
brand:
class: Pim\Bundle\CnetConnectorBundle\Entity\Brand
type: simple
Update Database & Assets
php bin/console cache:clear --env=prod --no-warmup
php bin/console doctrine:schema:update --env=prod --force
php bin/console --env=prod pim:installer:assets --symlink --clean
yarn run webpack
First Use Case: Import CNET Data
products.csv, reviews.csv).var/import/cnet/.php bin/console pim:cnet-connector:import
Data Enrichment Workflow
cnet_product_id, brand, specs) to Akeneo’s attribute structure.
Example: Extend Product entity to include CNET-specific attributes:
// config/akeneo_pim.yml
pim_enrich:
product:
attributes:
cnet_rating:
type: pim_catalog_enum
enum:
values:
- "1"
- "2"
- "3"
- "4"
- "5"
php bin/console pim:cnet-connector:import --file=products.csv
Scheduled Syncs
0 3 * * * php /path/to/akeneo/bin/console pim:cnet-connector:import >> /var/log/cnet_import.log 2>&1
Attribute Customization
ExtendedAttributeTypeBundle to add CNET-specific fields (e.g., cnet_review_url, cnet_category).
Example:
# config/akeneo_pim.yml
pim_enrich:
extended_attribute_type:
cnet_review_url:
type: pim_catalog_text
Brand Management
Brand entity (from pim_reference_data) to categorize products by manufacturer.php bin/console pim:reference-data:create brand "Sony" --locale=en_US
products.csv:
sku,cnet_product_id,brand,cnet_rating,specs
PROD-001,CN12345,Sony,4,"Resolution: 4K"
php bin/console pim:cnet-connector:validate --file=products.csv
CnetImportCommand class to fetch data via HTTP.Schema Mismatches
CnetImporter service to transform headers.
Example override:
# config/services.yml
services:
pim_cnet_connector.importer:
class: AppBundle\Service\CustomCnetImporter
arguments:
- '@pim_cnet_connector.importer.default'
// src/Service/CustomCnetImporter.php
class CustomCnetImporter extends \Pim\Bundle\CnetConnectorBundle\Importer\CnetImporter
{
protected function getFieldMappings()
{
return [
'cnet_product_id' => 'reference',
'brand' => 'brand', // Maps to reference data
'specs' => 'specs_text', // Custom attribute
];
}
}
Duplicate Entries
sku or cnet_product_id values.ProductUpdater to merge duplicates or skip updates with a flag:
php bin/console pim:cnet-connector:import --skip-duplicates
Locale Conflicts
fr_FR).// Override getSupportedLocales()
public function getSupportedLocales()
{
return ['en_US', 'fr_FR']; // Whitelist locales
}
Dependency Conflicts
CustomEntityBundle or ExtendedAttributeTypeBundle may conflict with other Akeneo extensions.Log Imports
Enable debug mode in config/packages/dev/monolog.yaml:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
Check logs for failed imports or missing fields.
Validate CSV
Use the validate command to catch format errors early:
php bin/console pim:cnet-connector:validate --file=products.csv --dry-run
Database Constraints
If imports fail with IntegrityConstraintViolationException, check:
sku or cnet_product_id.family, categories) are populated.Custom Importers
Extend CnetImporter to support additional CNET data sources (e.g., videos, news):
class VideoCnetImporter extends CnetImporter
{
protected function importFile($filePath)
{
// Custom logic for video data
}
}
Webhooks Trigger Akeneo workflows post-import (e.g., publish products):
// src/EventListener/CnetImportListener.php
class CnetImportListener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
'pim_cnet_connector.import.post' => 'onPostImport',
];
}
public function onPostImport(PostImportEvent $event)
{
$this->publishProducts($event->getProducts());
}
}
UI Integration
Add CNET-specific tabs to the Akeneo product grid using the pim_enrich_datagrid event:
# config/packages/pim_enrich.yaml
pim_enrich:
datagrid:
cnet:
label: CNET Data
fields:
- cnet_rating
- cnet_review_url
Testing Use PHPUnit to test importers:
public function testImportValidCsv()
{
$importer = $this->getImporter();
$result = $importer->import($this->getValidCsvPath());
$this->assertCount(1, $result->getProducts());
}
How can I help you explore Laravel packages today?