Helper methods - rocketweb-fed/magento2-theme-prime GitHub Wiki
RocketWeb_UiCore module comes with a set of helper methods that can be utilized to facilitate getting common catalog or user data.
To use a helper include it in your template file, eg.:
$productHelper = $this->helper('RocketWeb\UiCore\Helper\Product');
and call a specific method, eg.:
if ($productHelper->isShowPercentage()):
// do something
endif;
Helper methods are split into 4 groups:
- Customer
- Data
- Product
- Store
Customer
$helper->isLoggedIn()
Checks if the user is logged in
$helper->getCurrentCustomer()
Returns the current customer object
$helper->getCurrentCustomerGroup()
Returns the current customer group
Data
$helper->getEnable()
Returns true if UiCore module is enabled via admin
$helper->getStyleGuide()
Returns true if Style Guide page is enabled
$helper->isShareButtonsEnabled()
Returns true if social share buttons option is enabled
$helper->getShareButtonsCode()
Returns social share buttons code
Product
$helper->getCurrentCategory()
Gets the current category from the registry or from the first category of a product
$helper->getParentCategory()
Gets the parent category of the current category
$helper->getBackUrl()
Gets the back url when browsing products/categories, shop url is used as a fallback
$helper->getCurrentProduct()
Return the current product if available
$helper->getProduct()
Same as above but with error handling
$helper->isProductNew($product)
Returns true if product is new, false otherwise
$helper->isProductOnSale($product)
Checks if the product is on sale
$helper->getNewLabel()
Returns New product label from config
$helper->getSaleLabel()
Returns Sale product label from config
$helper->isShowPercentage()
Returns true if show percentage option is enabled in config
$helper->getSalePercentage($product)
Returns percentage off the original price for a specific product on sale
$helper->getProductLabels($product)
Returns product labels template
Store
$helper->getCurrentStore()
Returnss the current store
$helper->getLocale()
Returns the current locale, associated with the current store