Skip to main content

get configurable items of product magento 2

 $product_id = 25;

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$configProduct = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id);

foreach ($configProduct->getOptions() as $options)
{
    $optionData = $options->getValues();
    $parent_title = $options->getTitle();
    $parent_id = $options->getId();
    $parent[$parent_id] = $options->getTitle();
    foreach ($optionData as $data) {
        /* echo '<pre>';
         print_r($data->getData());
        echo '</pre>'; */
        $optionPrice [ $data['option_id'] ][ $data['title'] ] = $data->getPrice();
        $optionid [ $data['option_id'] ][ $data['title'] ] = $data['option_type_id'];
    }
}

$optionPricemyJSON = json_encode( $optionPrice );   

Comments

Popular posts from this blog

Magento 2: Category list for custom magento system configuration section ( Backend )

In system.xml file field for multi select of category is like: NOTE: Use Select for Single item and multiselect for multiple in - <field id = "bannerlist" translate = "label" type = " multiselect " <group id = "bannerblock_setting" translate = "label" type = "text" delault = "1" sortOrder = "3" showInDefault = "1" showInWebsite = "1" showInStore = "1" > <label> Setting </label> <field id = "bannerlist" translate = "label" type = "multiselect" sortOrder = "10" showInDefault = "1" showInWebsite = "1" showInStore = "1" > <label> Select Category </label> <!-- <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>--> <source_model> Ipragmatech\Bannerblock\Model\Config\Source\C...

Magento2: How to install custom theme in magento 2

magento2 | _ app | _ design | _ frontend | _ Custom | _theme | _Magento_Theme | _templates | _root . phtml - Copy of Luma | _registration . php | _theme . xml     Your path for registration.php is app\design\frontend\Custom\theme\registration.php   <? php \Magento\Framework\Component\ComponentRegistrar :: register ( \Magento\Framework\Component\ComponentRegistrar :: THEME , 'frontend/Custom/theme' , __DIR__ );       app\design\frontend\Custom\theme\theme . xml   <theme xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "urn:magento:framework:Config/etc/theme.xsd" > <title> Custom Theme </title> <parent> Magento/luma </parent> <media> <preview_image> media/preview.jpg </preview_image> </media...