Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The process for saving newly created product data in the extended Shopware 6 Product Entity involves the following steps:

  1. Create a new instance of the extended product entity.
  2. Set the values of the new fields in the product entity.
  3. Save the product entity using the Shopware 6 Entity Manager.
  4. Flush the changes to the persistence layer to persist the new product data.

Here's an example of how to save a newly created product entity:

// Create a new instance of the extended product entity
$product = new ExtendedProductEntity();

// Set the values of the new fields in the product entity
$product->setName('New Product');
$product->setPrice(9.99);
$product->setCustomField('Custom field value');

// Save the product entity using the Shopware 6 Entity Manager
$entityManager = $this->container->get('doctrine.orm.default_entity_manager');
$entityManager->persist($product);

// Flush the changes to the persistence layer to persist the new product data
$entityManager->flush();

After the product data is saved, it can be retrieved and displayed in the storefront or in the backend.