i am using magento 2.3 and i want to products
and category
hide , if customer not login means i want to hide product and category page hide for guest customer and must be redirect to login page
1 Answer
You can write on breadcrumb.phtml
page By Objectmanager like this :
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$request = $objectManager->get('\Magento\Framework\App\Request\Http');
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
if(!$customerSession->isLoggedIn()) {
if($request->getFullActionName() == 'catalog_category_view' || $request->getFullActionName() == 'catalog_product_view') {
$url = $block->getBaseUrl().'customer/account/';
header('Location: '.$url);
}
}