Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello all, I am extending the DataImport with the following writer. ```/** * @inheritDoc

Options
U048WDEP3R7
U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet

Hello all,

I am extending the DataImport with the following writer.

/**
     * @inheritDoc
     */
    public function write(DataSetInterface $dataSet)
    {
        $this->setDataSetWriterPersistenceState(false);

        $spyProductQuery = SpyProductAbstractQuery::create()
            ->filterBySku($dataSet[static::KEY_ATTRIBUTES])
            ->findOneOrCreate();

        $spyProductQuery->setAttributes($dataSet[static::KEY_ATTRIBUTES]);
        $spyProductQuery->setSku($dataSet[static::KEY_SKU]);
        $spyProductQuery->save();

        $spyProductLocalizedAttributesQuery = SpyProductLocalizedAttributesQuery::create()
            ->filterByfkproduct($spyProductQuery->getIdProductAbstract())
            ->findOneOrCreate();

        $spyProductLocalizedAttributesQuery->setFkLocale(66);
        $spyProductLocalizedAttributesQuery->setFkProduct($spyProductQuery->getIdProductAbstract());
        $spyProductLocalizedAttributesQuery->setAttributes($dataSet[static::KEY_ATTRIBUTES]);
        $spyProductLocalizedAttributesQuery->setDescription('placeholder description');
        $spyProductLocalizedAttributesQuery->setName($dataSet[static::KEY_ATTRIBUTES]);
        $spyProductLocalizedAttributesQuery->save();
    }

When I run the import, I get the following error. Can someone please advise me what I might be doing wrong? The code up to $spyProductQuery->save(); is running file. Something after this is giving me the following error:

Starting import with /data/data/import/local/full_EU.yml configuration file.
Spryker\Zed\DataImport\Business\Exception\DataImportException - Exception: Unable to execute INSERT statement [INSERT INTO `spy_product_localized_attributes` (`id_product_attributes`, `fk_locale`, `fk_product`, `attributes`, `description`, `name`, `created_at`, `updated_at`) VALUES (:p0, :p1, :p2, :p3, :p4, :p5, :p6, :p7)]

DataImport for "aep-import-abstract-product" at data set position "1" has an error.

For debugging execute "vendor/bin/console data:import:aep-import-abstract-product -o 1 -l 1 -t"

Comments

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    gibt es die Locale 66 in your spy_locale table?

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @UL65CH0MC Yes there is

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    then please take a look in propel.log..
    maybe smth is missing and propel try to do an insert instead an update..

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    you can turn the propel debug on and then you will see the complete statement. copy and run it directly.

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @UL65CH0MC Can you please tell me where is propel.log located?

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    for propel.log you have to enable the propel debug first

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @UK7KBE2JW Is there reference documentation on how to enable it in Spryker?

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    Dunno if there is a reference in documentation. Some reference is taking a look into the config from those modules.

    $config[PropelConstants::PROPEL_DEBUG] = true;
    $config[PropelOrmConstants::PROPEL_SHOW_EXTENDED_EXCEPTION] = true;