PHP code example of creativestyle / magesuite-elasticsuite-virtual-category-indexer

1. Go to this page and download the library: Download creativestyle/magesuite-elasticsuite-virtual-category-indexer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

creativestyle / magesuite-elasticsuite-virtual-category-indexer example snippets


public function getCategorySearchQuery($category, $excludedCategories = []): ?QueryInterface
{
    $query = null;

    if (!is_object($category)) {
        $category = $this->categoryFactory->create()->setStoreId($this->getStoreId())->load($category);
    }

    if (!in_array($category->getId(), $excludedCategories)) {
        $excludedCategories[] = $category->getId();

        if ((bool) $category->getIsVirtualCategory() && $category->getIsActive()) {
           $query = $this->getVirtualCategoryQuery($category, $excludedCategories, $category->getData('virtual_category_root'));
        } elseif ($category->getId() && $category->getIsActive()) {
            $query = $this->getStandardCategoryQuery($category, $excludedCategories);
        }
        if ($query && $category->hasChildren()) {
            $query = $this->addChildrenQueries($query, $category, $excludedCategories);
        }
    }

    return $query;
}