Skip to content

Instantly share code, notes, and snippets.

@saiik
Last active November 30, 2016 10:52
Show Gist options
  • Select an option

  • Save saiik/60212a240e37049daf4572da3b336b47 to your computer and use it in GitHub Desktop.

Select an option

Save saiik/60212a240e37049daf4572da3b336b47 to your computer and use it in GitHub Desktop.
Add & delete Shopware Attributes using the new CRUD feature
<?php
$attr = Shopware()->Container()->get("shopware_attribute.crud_service");
$attr->update(
"attributes_table",
'your_field_name',
'field_type',
[
'label' => 'Display Label',
'displayInBackend' => true,
'position' => 1
]
);
$meta = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
$meta->deleteAll();
Shopware()->Models()->generateAttributeModels(
['attributes_table']
);
<?php
$attr = Shopware()->Container()->get('shopware_attribute.crud_service');
$attr->delete(
'attributes_table',
'your_field'
);
$meta = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
$meta->deleteAll();
Shopware()->Models()->generateAttributeModels(
['attributes_table']
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment