6 declare(strict_types=1);
9 use Magento\Bundle\Api\Data\LinkInterfaceFactory;
11 use Magento\Bundle\Api\Data\OptionInterfaceFactory;
28 $installer = Bootstrap::getObjectManager()->create(CategorySetup::class);
31 $website = Bootstrap::getObjectManager()->create(Website::class);
32 $website->load(
'us_website',
'code');
39 $product = Bootstrap::getObjectManager()->create(Product::class);
40 $product->setTypeId(Type::TYPE_SIMPLE)
47 ->setVisibility(Visibility::VISIBILITY_BOTH)
48 ->setStatus(Status::STATUS_ENABLED)
49 ->setStockData([
'use_config_manage_stock' => 1,
'qty' => 100,
'is_qty_decimal' => 0,
'is_in_stock' => 1]);
55 $registry = Bootstrap::getObjectManager()->get(Registry::class);
57 $registry->register(
'isSecureArea',
true);
66 'product_id = ' . $productToDelete->getId()
72 $registry->register(
'isSecureArea',
false);
81 ->setAttributeSetId(4)
82 ->setName(
'Bundle Product')
84 ->setVisibility(Visibility::VISIBILITY_BOTH)
85 ->setStatus(Status::STATUS_ENABLED)
86 ->setStockData([
'use_config_manage_stock' => 1,
'qty' => 100,
'is_qty_decimal' => 0,
'is_in_stock' => 1])
91 ->setBundleOptionsData(
94 'title' =>
'Bundle Product Items',
95 'default_title' =>
'Bundle Product Items',
102 ->setBundleSelectionsData(
107 'selection_qty' => 1,
108 'selection_can_change_qty' => 1,
119 $option = Bootstrap::getObjectManager()->create(OptionInterfaceFactory::class)
125 if (!empty($bundleLinks[$key])) {
126 foreach ($bundleLinks[$key] as
$linkData) {
129 $link = Bootstrap::getObjectManager()->create(LinkInterfaceFactory::class)
132 $link->setSku($linkProduct->getSku());
134 if (isset(
$linkData[
'selection_can_change_qty'])) {
135 $link->setCanChangeQuantity(
$linkData[
'selection_can_change_qty']);
153 ->create(CategoryLinkManagementInterface::class);