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


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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.