Magento 2 – create customizable options programmatically

You may also like...

9 Responses

  1. Udo says:

    Looks good to us, thank you!

    We have imported our products from our old shop system to Magento 2 and we are facing an issue with customizable options. As the major snippet for programmatically editing options already exists her, it might be an interesting job to create a module that basically runs through all our products, looks for specific customizable options and then changes the options of these articles in the database. Finally, an update of the phtml for product view would be required (showing some attributes only when the first attribute is selected).

    We would be happy to hear a proposal from somebody đŸ™‚

    It would deal with

  2. dariel says:

    Hi,

    where to save the file? I can’t find the filename/path of the script.

    • magemaster says:

      you can create a simple script for it and place it in your Magento root (fast and simple solution), or better: create a new module and put it into a class.

  3. Himanshu says:

    I got error Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (catalog_product_option_type_price, CONSTRAINT FK_CF381633CBDBD1124AC83B128A5B72A8 FOREIGN KEY (option_type_id) REFERENCES when use below code in magento 2.2.6

  4. Hardik Makwana says:

    Hello,

    Product Option was created successfully via ‘catalog_product_save_after’ event but into the frontend the product options is not appearing

Leave a Reply