I am extending Magento_ProductAlert
module. By default when subscribing to product it saves configurable product id but I have managed to get selected simple product ID. And later I know that I can get my product url by $product->getProductUrl()
but in this case it doesn't work for me because simple products are not visible individually, only in configurable products and using that it returns me link to simple product like this - http://mysite/myproduct-123
but is there a way how can I retrieve configurable product url but with attributes that respond to my simple product? I mean like this - http://mysite/myconfigurableproduct#123=12
Thank you!
When sending email to user that he has subscribed to product I am using this -
<?php if ($_products = $block->getProducts()): ?>
<?php foreach ($_products as $_product): ?>
<p><?= __('Hello!') ?></p>
<p>
<?= __(
'You have subscribed for product: <strong class="product name"><a href="%1">%2</a></strong>',
$_product->getProductUrl(),
$block->escapeHtml($_product->getName())
)
?>
</p>
<p>
<a href="<?= $block->getUserUnsubscribeUrl() ?>">
<?= __('Click here to stop alerts for this product.') ?>
</a>
</p>
<?php endforeach ?>
<?php endif ?>