0

When I create new product type and extend Bundle, I don`t have "Bundle Items" tab, how I can get the same functionality in my custom product type like in Bundle product? enter image description here

product_type.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd"> <type name="super_bundle" label="Super Bundle Product" modelInstance="Vendor\Module\Model\Product\Type" composite='true' indexPriority="40" sortOrder="50"> <priceModel instance="Magento\Bundle\Model\Product\Price" /> <indexerModel instance="Magento\Bundle\Model\ResourceModel\Indexer\Price" /> <stockIndexerModel instance="Magento\Bundle\Model\ResourceModel\Indexer\Stock" /> <allowedSelectionTypes> <type name="virtual" /> </allowedSelectionTypes> <customAttributes> <attribute name="refundable" value="true"/> </customAttributes> </type> </config>

When I use

----------

3

1 Answer 1

1

I hope you were both able to Figure out your issue, If not I believe the Following should be the fix.

<vendor>/<module>/etc/product_types.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd">
    <type name="custom_bundle" label="Custom Bundle Product" modelInstance="<vendor>\<module>\Model\Product\Type" composite='true' indexPriority="40" sortOrder="50">
        <priceModel instance="Magento\Bundle\Model\Product\Price" />
        <indexerModel instance="Magento\Bundle\Model\ResourceModel\Indexer\Price" />
        <stockIndexerModel instance="Magento\Bundle\Model\ResourceModel\Indexer\Stock" />
        <allowedSelectionTypes>
            <type name="simple" />
            <type name="virtual" />
        </allowedSelectionTypes>
        <customAttributes>
            <attribute name="refundable" value="true"/>
        </customAttributes>
    </type>
</config>

<vendor>/<module>/Model/Product/Type.php:

<?php

namespace <vendor>\<module>\Model\Product;

/**
 * Class Type
 * @package <vendor>\<module>\Model\Product
 */
class Type extends \Magento\Bundle\Model\Product\Type {

    const TYPE_CODE = 'custom_bundle';

    // Class Intentionally left blank
}

<vendor>/<module>/Setup/InstallData.php:

namespace <vendor>\<module>\Setup;

use Magento\Eav\Setup\EavSetup;
use \Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Catalog\Model\Product;
use <vendor>\<module>\Model\Product\Type as CustomPoductType;

/**
 * Class InstallData
 * @package <vendor>\<module>\Setup
 */
class InstallData implements InstallDataInterface
{
    /**
     * EAV setup factory
     *
     * @var EavSetupFactory
     */
    private $eavSetupFactory;

    /**
     * Init
     *
     * @param EavSetupFactory $eavSetupFactory
     */
    public function __construct(EavSetupFactory $eavSetupFactory)
    {
        $this->eavSetupFactory = $eavSetupFactory;
    }

    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        /** @var EavSetup $eavSetup */
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

        $fieldList = [
            'price',
            'special_price',
            'special_from_date',
            'special_to_date',
            'minimal_price',
            'cost',
            'tier_price',
            'weight',
            'price_type',
            'sku_type',
            'weight_type',
            'price_view',
            'shipment_type',
        ];

        foreach ($fieldList as $field) {
            $applyTo = explode(',', $eavSetup->getAttribute(Product::ENTITY, $field, 'apply_to'));

            if (!in_array(CustomPoductType::TYPE_CODE, $applyTo)) {
                $applyTo[] = CustomPoductType::TYPE_CODE;
                $eavSetup->updateAttribute(
                    Product::ENTITY,
                    $field,
                    'apply_to',
                    implode(',', $applyTo)
                );
            }
        }
    }
}

From your question i think the main part you are missing is the EAV Attributes assignment. if you were to take a look at the Magento_Bundle module Setup/InstallData.php you will see that this has a list of existing attributes that it assigns plus creates some new ones, it is the new attributes that are required, specifically shipment_type for the highlighted area in the screenshot.

4
  • add option button still missing..... Commented Jan 25, 2019 at 19:37
  • Also, if enable dynamic price the price is not disabling.. Do we need edit any other files apart from these three?
    – aravind
    Commented Feb 24, 2020 at 13:01
  • Thank you @Nathan Day after add missing attribute in apply_to showing bundle item tab but still missing add option button have you any idea for the same Commented Mar 22, 2021 at 12:07
  • @SagarDobariya this is the answer: magento.stackexchange.com/questions/258316/…
    – Guru
    Commented Oct 19, 2021 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.