I have a piece of code that I am converting from magento 1 to magento 2. This is the code that has been converted
$productType = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE;
$bundleType = null;
if (null !== $mainVariationIndex) {
$isActive = isset($item['variations'][$mainVariationIndex]['isActive']) ? $item['variations'][$mainVariationIndex]['isActive'] : false;
if (count($item['variations']) > 1) {
$productType = \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE;
}
if (isset($item['variations'][$mainVariationIndex]['bundleType'])) {
$bundleType = $item['variations'][$mainVariationIndex]['bundleType'];
$productType = $bundleType === \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE ?
\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE : \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE;
}
}
I am having the issue in this line
$productType = \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE;
The above line was like this in magento 1.9
$productType = Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE;
Now when I am using the constant TYPE_CONFIGURABLE in magento 2, I am getting an error Undefined class constant. So I checked for constant in file Type.php in catalog module for magento 2 but did not find it. There were only three constants defined
const TYPE_SIMPLE = 'simple';
const TYPE_BUNDLE = 'bundle';
const TYPE_VIRTUAL = 'virtual';
So I thought it must be defined in some other file but could not find it. Now my question is should I use configurable as a string like below
$productType = 'configurable';
for my code in magento 2 or there is some other way.