Magento – Get Visibility of product Magento 2

magento2productvisibility

I want to know how to get visibility of product using Magento 2. I have a product that is set to "not visible individually" and want to remove it from a collection.

I have tried below methods:

$product->getVisiblility();
$product->getVisibleInCatalogStatuses();
$product->getVisibleStatuses();
$product->isVisibleInCatalog();
$product->getVisibleInSiteVisibilities();
$product->isVisibleInSiteVisibility();

But all products return the same value "1" for $product->isVisibleInCatalog visible or not.

I have reindexed via command line also and set the visibility for all stores to be not visible however still the issue persists.

Best Answer

You can get it via this :

$_product->getAttributeText('visibility');

Get visiblity text:

$_product->getAttributeText('visibility')->getText();
Related Topic