Last active
March 31, 2022 07:16
-
-
Save mohfahrul/9f792bcc754751de28ee393fa7f7ad1a to your computer and use it in GitHub Desktop.
Make Path Url with Base Url - Helper Magento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Icube\Training\Helper; | |
use Magento\Framework\App\Helper\Context; | |
use Magento\Store\Model\StoreManagerInterface; | |
class Kuli extends \Magento\Framework\App\Helper\AbstractHelper | |
{ | |
public $_storeManager; | |
public function __construct( | |
StoreManagerInterface $storeManager | |
){ | |
$this->_storeManager = $storeManager; | |
} | |
public function urlPath( $path ){ | |
$baseUrl = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB); | |
return $baseUrl . $path; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Icube\Training\Block; | |
class Use extends \Magento\Framework\View\Element\Template | |
{ | |
protected $helperKuli; | |
public function __construct( | |
\Icube\Training\Helper\Kuli $helperKuli | |
){ | |
$this->_helperKuli = $helperKuli; | |
} | |
public function urlPath( $path ){ | |
return $this->_helperKuli->urlPath( $path ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment