Skip to content

Instantly share code, notes, and snippets.

@mohfahrul
Last active March 31, 2022 07:16
Show Gist options
  • Save mohfahrul/9f792bcc754751de28ee393fa7f7ad1a to your computer and use it in GitHub Desktop.
Save mohfahrul/9f792bcc754751de28ee393fa7f7ad1a to your computer and use it in GitHub Desktop.
Make Path Url with Base Url - Helper Magento
<?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;
}
}
<?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