To get configure product id from its the simple product use below code.
namespace Vendor\Frontendsample\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action
{
protected $configure;
protected $resultPageFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configure
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\ConfigurableProduct\Model\Product\Type\Configurable $configure
){
$this->configure = $configure;
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
public function execute()
{
$productId = 12;//your simple product id of configure product
$parentIds = $this->configure->getParentIdsByChild($productId);
$parentId = array_shift($parentIds);
print_r($parentId);
}
}
If you getting nothing from above code, then you should check child(simple) product id of parent(configure) product id, may be its wrong or may be something wrong with your configure product in admin side.