I want to import downloadble product when i was importing catalog_product.csv it's giving me below error:

  1. Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s): 1
  2. Error move file in row(s): 1 General system exception happened Additional data: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'website_id' cannot be null, query was: INSERT INTO downloadable_link_price (price_id,link_id,website_id,price) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE price_id = VALUES(price_id), link_id = VALUES(link_id), website_id = VALUES(website_id), price = VALUES(price)
  • Do you use website id columns in csv?
    – shail
    Jul 6, 2018 at 8:27
  • No, it's set in code default Like dlp.website_id=' . self::DEFAULT_WEBSITE_ID, Jul 6, 2018 at 8:29
  • Check below link May be it will help you :github.com/magento/magento2/issues/2666
    – shail
    Jul 6, 2018 at 8:43
  • There are not reference for downloadable product Jul 6, 2018 at 9:13
  • Yes not for specific for downlodable product, but its regarding product import issue as same as yours. Are you able to import simple product using csv?
    – shail
    Jul 6, 2018 at 9:23

2 Answers 2

/*if (count($dataLink['price'])) {
            $this->downloadableHelper->prepareDataForSave($this->dataLinkPrice, $dataLink['price'])

Commenting above code from Magento\DownloadableImportExport\Model\Import\Product\Type\Downloadable.php Fixes myissue


The problem is in the method fillDataTitleLink(array $options) in vendor/magento/module-downloadable-import-export/Import/Product/Type/Downloadable.php.

It does a select query from the downloadable_link table, with a left join on the downloadable_link_price table, on link_id and website_id.

However, since the row has not yet been inserted into the downloadable_link table, the result of the query fills link_id and website_id as NULL.

Then, when setting the var $existOption, it calls fillExistOptions($this->dataLinkPrice, $option, $existingOptions).

(fillExistOptions: https://www.magentoextensions.org/documentation//class_magento_1_1_downloadable_import_export_1_1_helper_1_1_data.html)

fillExistOptions sets the result using array_replace($base, $option, $existingOption). This replaces link_id and website_id with NULL, which ultimately causes the error. It returns $result['price'] with the null values, which is then used in saveLinkOptions() as $dataLink['price'] in insertOnDuplicate(...).

fillDataTitleLink() is called in saveLinkOptions() BEFORE the latter method inserts the row into the downloadable_link_price table.

The only solution I have found so far, and it has been working for me, is to add this in fillDataTitleLink, after $existingOptions is set with the select query:

foreach($existingOptions as $k=>$v):
  if($k['website_id'] == NULL):
    $existingOptions[$k]['website_id'] = self::DEFAULT_WEBSITE_ID;

Still investigating if there's a better way to solve it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.