$this->getProductTypes()]; } /** * Returns an array of product types * * @return array|null * @throws \Magento\Framework\Exception\LocalizedException */ private function getProductTypes() { if ($this->productTypes === null) { $this->productTypes = []; $block = $this->getLayout()->getBlock('category.products.list'); if ($block) { $productCollection = $block->getLoadedProductCollection(); $productTypes = []; /** @var $product \Magento\Catalog\Model\Product */ foreach ($productCollection as $product) { $productTypes[] = $this->escapeHtml($product->getTypeId()); } $this->productTypes = array_unique($productTypes); } } return $this->productTypes; } /** * {@inheritdoc} * @since 100.1.0 */ protected function _toHtml() { if (!$this->getProductTypes()) { return ''; } return parent::_toHtml(); } }