Skip to content

Instantly share code, notes, and snippets.

@kevinzie
Created August 2, 2018 04:04
Show Gist options
  • Save kevinzie/9965d088550527a65ecfafb66cf1a7c0 to your computer and use it in GitHub Desktop.
Save kevinzie/9965d088550527a65ecfafb66cf1a7c0 to your computer and use it in GitHub Desktop.
Magento 2 Http Request Detection.
<?php
namespace Jackrose\Catalog\Block\Product;
class TrendingProduct extends \Magento\Framework\View\Element\Template
{
...
protected $_request;
...
public function __construct(
...
\Magento\Framework\App\Request\Http $request,
...
)
{
...
$this->_request = $request;
...
}
public function getSystemCategory() {
if ($this->_request->getFullActionName() == 'cms_index_index') {
...
}
if($this->_request->getFullActionName() == 'catalog_category_view') {
...
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment