Links purchased separately default to true when importing downloadable products #38465
Description
Preconditions and environment
- Magento version 2.4.6 and 2.4.4
- Apache
- php 8.1
- MySQL 8.0.22
Tested on both above versions.
Steps to reproduce
- Import attached csv file. It was exported by a vanilla Magento 2.4.4.
- Check created product.
export_catalog_product_20240222_205229.test.csv
Expected result
Links purchased seperately checkbox should be unticked.
Actual result
Links purchased seperately checkbox is ticked, even though in the import it is 0 (false).
Additional information
In /module-downloadable-import-export/Model/Import/Product/Type/Downloadable.php, this function:
/**
* Get additional attributes for downloadable product.
*
* @param array $rowData
* @return array
*/
protected function addAdditionalAttributes(array $rowData)
{
return [
'samples_title' => $this->sampleGroupTitle($rowData),
'links_title' => $this->linksAdditionalAttributes($rowData, 'group_title', self::DEFAULT_GROUP_TITLE),
'links_purchased_separately' => $this->linksAdditionalAttributes(
$rowData,
'purchased_separately',
self::DEFAULT_PURCHASED_SEPARATELY
)
];
}
is looking for "purchased_separately" in the "downloadable_links" column which needless to say doesn't contain this field. However, if we add it, like so:
link_id=1,id=1,purchased_separately=0,title=asdasdasd,sort_order=1,price=0.000000,is_shareable=1,link_type=file,link_file=/s/y/sycamore_row-john_grisham.epub
The import will succeed with links_purchased_separately as unticked. This does not make sense, because links_purchased_separately should be a global field, for all download links not per download link item, and besides, the export exports links_purchased_separately in the "additional_attributes" column, not the "downloadable_links" column.
From what I can tell, the "additional_attributes":
links_purchased_separately=0,links_title=Links,samples_title=Samples
is parsed and merged in $rowData, but somehow ignored. Someone mentioned that the constant self::DEFAULT_PURCHASED_SEPARATELY is wrong being set to true, and should be set to false, but I don't believe that is the correct fix.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Assignees
Labels
Type
Projects
Status
Ready for Development