Case1:
Rewrite the class Mage_Catalog_Block_Widget_Link and on the rewite class add new funtoin getProductId()
on
public function getProductId()
{
if($this->hasStoreId()) {
$store = Mage::app()->getStore($this->getStoreId());
} else {
$store = Mage::app()->getStore();
}
if ($this->getData('id_path')) {
/* @var $urlRewriteResource Mage_Core_Model_Mysql4_Url_Rewrite */
$urlRewriteResource = Mage::getResourceSingleton('core/url_rewrite');
$pID = $urlRewriteResource->getProductPathByIdPath($this->getData('id_path'), $store);
return $pID;
}
return null;
}
Case2:
Rewrite the class Mage_Core_Model_Resource_Url_Rewrite
and on the rewrite class add new funtoin getProductPathByIdPath()
,which will get product
public function getProductPathByIdPath($idPath, $store)
{
if ($store instanceof Mage_Core_Model_Store) {
$storeId = (int)$store->getId();
} else {
$storeId = (int)$store;
}
$select = $this->_getReadAdapter()->select();
/** @var $select Varien_Db_Select */
$select->from(array('main_table' => $this->getMainTable()), 'product_id')
->where('main_table.store_id = :store_id')
->where('main_table.id_path = :id_path')
->where('main_table.product_id IS NOT NULL)
->limit(1);
$bind = array(
'store_id' => $storeId,
'id_path' => $idPath
);
return $this->_getReadAdapter()->fetchOne($select, $bind);
}
this function get Product Id
Case3:
Rewrite the class Mage_Checkout_Helper_Car
and on the rewrite class add new funtoin getmyAddUrl
().By using this you can get cart url
public function getmyAddUrl($productId, $additional = array())
{
$continueUrl = Mage::helper('core')->urlEncode($this->getCurrentUrl());
$urlParamName = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED;
$routeParams = array(
$urlParamName => $continueUrl,
'product' => $productId
);
if (!empty($additional)) {
$routeParams = array_merge($routeParams, $additional);
}
return $this->_getUrl('checkout/cart/add', $routeParams);
}
Best Answer
There is a solution suggested at https://www.atwix.com/magento-2/alternatives-for-deprecated-registry-class-magento-2-3/
Also, there is discussion in the comment section of the article on the other alternative options.