Skip to main content
1 of 4
Tu Van
  • 7.8k
  • 2
  • 14
  • 24
  1. 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>
  1. 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'
    ),
],
  1. Add an upload controller to handle selection image upload.
  2. 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());
}
  1. Run the commands to upgrade database, re-compile code, re-deploy static content.
Tu Van
  • 7.8k
  • 2
  • 14
  • 24