- Add a new field for selection image to
catalog_product_bundle_selection
table.
Assuming you use Magento version >= 2.3, create <your module dir>/etc/db_schema.xml
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="catalog_product_bundle_selection">
<column xsi:type="varchar" name="selection_image" nullable="true" length="255" comment="Selection Image"/>
</table>
</schema>
- In your custom
BundleCustomOptions
Modifier, add uploaderConfig
to your selection image field to point to the uploader controller.
'uploaderConfig' => [
'url' => $this->urlBuilder->getUrl(
'bundleselectionimage/product_image/upload'
),
],
- Add an upload controller to handle selection image upload.
- Override
Magento\Bundle\Model\LinkManagement
to save the selection image value to database.
At the end of the mapProductLinkToBundleSelectionModel
method, before return $selectionModel;
, adding the below code:
if ($productLink->getSelectionImage() !== null) {
$selectionModel->setSelectionImage($productLink->getSelectionImage());
}
- Run the commands to upgrade database, re-compile code, re-deploy static content.