Magento 2 Get Parent Product id from child id.

Magento 2 Get Configurable product id from Child id of configurable. When you have Child id of the P product is available you can simply get the parent config product id.

Create simple block to get parent product id,

now call the function in template file to get Parent Id,

 

 

How to import configurable product in magento 2 using CSV?

You can import configurable products in Magento 2 by CSV from admin panel.
Log in to admin panel with your credentials.
Go To System -> Data Transfer -> Import
From Entity Type Select Products.
Select Add/Update from Import Behavior settings.

For Import Configurable product using csv, first verify its simple product exist or not in catalog, If child product is not available in catalog, You must create first its child product or Assigned all the child product in CSV before configurable product row.

You are familiar with simple product import. if you dont know how to import simple product please refer link.How to import simple product in Magento 2?

From simple product to configurable product main difference in column are configurable_variations and configurable_variation_labels
Both column is must required to import configurable product.

configurable_variation_labels => size=Size,color=Color
Super attribute code if the configurable product made with multiple attribute keep value with comma separated.
Example, where size, color(lowercase) is attributed code and Size and Color(attribute label)

configurable_variations => It contains the pair of all the child product SKU, super attribute value separated with PIPE(|) operator.

Example,
sku=Test Simple 1,size=S,color=Red|sku=Test Simple 2,size=M,color=Blue|sku=Test Simple 3,size=L,color=White|sku=Test Simple 4,size=XL,color=Yellow

Where sku=Test Simple 1,size=S,color=Red (simple product 1 sku and color and size value) for second product we must use pipe(|) operator and set value of second simple product and so on.

Don’t forget to run  indexer command,
php bin/magento indexer:reindex

Download Configurable Product Import Sheet.

Magento 2 How to get child item id of configurable product by super attribute details?

Let’s assume you know configurable product id and used child product super attribute details.
Example from Magento Sample data configurable product name Chaz Kangeroo Hoodie,  Configurable product id is 67.
Super attribute Array details,

Using the bove details how we can get details of child item.

Refer below code snippet for Get child item id of a Configurable product by child’s Attribute details.

Call function,

Result is 52(Product name Chaz Kangeroo Hoodie-XS-Black). Using above way we got the child item data.