Using Magento 2, You can fetch Parent product Ids as an array from the child id of the product.
To Retrieve the Parent product id, You need Child Item Id associated with Grouped Product. Using Magento\GroupedProduct\Model\Product\Type\Grouped Magento Core class you can fetch the parent product Id.
For More Knowledge check the article, You can fetch All the children’s items by Grouped Product SKU.
Used function getParentIdsByChild($childProductId)
You need to pass the first parameter as $childProductId for getting the parent product ID of the child item id.
$childIds = 33; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $parentId = $objectManager->create('Magento\GroupedProduct\Model\Product\Type\Grouped')->getParentIdsByChild($childIds); echo "<pre>";print_r($parentId);
You can call Grouped Class in your Block __construct function, Create Block class,
public function __construct( \Magento\GroupedProduct\Model\Product\Type\Grouped $groupedProduct ) { $this->groupedProduct = $groupedProduct; } /** * $childId Child Item id */ public function getGroupedProductId($childId) { $this->groupedProduct->getParentIdsByChild($childId); }
Call from a template file,
$childrenItemID = 33;
echo $block->getGroupedProductId($childrenItemID);
Sir any tutorial on how to add custom display mode in category admin side,on selected custom display mode,change the category page.
For example already options like, product only,static block or product and static block both…
So one custom option in this drop-down,and on select change the category page according to the custom option
Sir any tutorial on how to add custom display mode in category admin side,on selected custom display mode,change the category page.
For example already options like, product only,static block or product and static block both…
So one custom option in this drop-down,and on select change the category page according to the custom option