Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Cloning a product without attributes doesn't work #24

Open
thomasheller opened this issue Feb 19, 2020 · 1 comment
Open

Cloning a product without attributes doesn't work #24

thomasheller opened this issue Feb 19, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@thomasheller
Copy link

thomasheller commented Feb 19, 2020

Steps to reproduce:

  1. Install flagbit/akeneo-product-cloner.
  2. Create new product in Akeneo. Make sure the product has no attributes.
  3. Select "Clone" from the menu.
  4. Enter a product code.
  5. Click "Save".

Actual result:

Blank dialog appears. The product is not cloned.

var/logs/prod.log shows:

request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Cannot use object of type stdClass as array" at /srv/pim/vendor/flagbit/product-cloner-bundle/src/Controller/AbstractController.php line 41 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot use object of type stdClass as array at /srv/pim/vendor/flagbit/product-cloner-bundle/src/Controller/AbstractController.php:41)"} []

Expected result:

Product should be cloned (or at least an error message should appear in the dialog).

@thomasheller thomasheller added the bug Something isn't working label Feb 19, 2020
@igormukhingmailcom
Copy link

The reason is:

The solution:

abstract class AbstractController extends Controller
...
    protected function normalizeProduct(EntityWithFamilyVariantInterface $product)
    {
        $normalizedProduct = $this->getNormalizer()->normalize($product, 'external_api');

        # @see https://github.com/flagbit/akeneo-product-cloner/issues/24
        if ($normalizedProduct['values'] instanceof \stdClass) {
            $normalizedProduct['values'] = [];
        }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants