- Follow this guide: https://developer.shopware.com/docs/guides/plugins/plugins/plugin-base-guide
- Install the plugin with
composer require name/of-the-plugin
to make shopware recognize it bin/console plugin:refresh
- Install it:
bin/console plug:in --activate NameOfThePlugin
- Cache clear
bin/console ca:c
Basically, in your plugin class:
public function update(UpdateContext $updateContext): void
{
$this->addCustomProductField($updateContext);
}
protected function addCustomProductField(UpdateContext $updateContext)
{
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
$customFieldSetRepository->create([
[
'name' => 'custom_product_detail',
'config' => [
'label' => [
'en-GB' => 'Product Detail Fields',
'de-DE' => 'Produktdetailfelder',
],
],
'customFields' => [
[
'name' => 'custom_product_detail_faq',
'type' => CustomFieldTypes::HTML,
'config' => [
'type' => CustomFieldTypes::HTML,
'label' => [
'en-GB' => 'FAQ',
'de-DE' => 'FAQ',
],
'componentName' => 'sw-text-editor',
'customFieldType' => 'textEditor',
'customFieldPosition' => 3,
],
],
],
],
], $updateContext->getContext());
}
Using the container in a migration in combination with the ContainerAwareTrait
does not work, hence the update script in the plugin class.
Then run
bin/console plugin:update <Plugin Name>
https://developer.shopware.com/docs/guides/plugins/plugins/storefront/add-custom-assets