@param array $productData
@param array $categories

@return array
501906
protected function buildProductCategories(array &$productData, array $categories)
    {
        /** @var array $categories */
        foreach ($categories as $category) {
            $productData['categories'][] = [
                'code' => (string) $this->arrayExtract($category, 'code', ''),
                'name' => (string) $this->arrayExtract($category, 'name', ''),
            ];
        }

        return $productData;
    }
1129578
public function getComponentsWithCategory($category)
    {
        $components = array();
        foreach ($this->blockConfiguration as $blockComponent => $configuration) {
            if (isset($configuration['category']) && $category === $configuration['category']) {
                $components[] = $blockComponent;
            }
        }

        return $components;
    }
700311
public function findEntitiesByCategoryIdsAndTags($locale, array $categoryIds = [], array $tags = [])
    {
        $products = $this->productRepository->findByCategoryIdsAndTags($locale, $categoryIds, $tags);

        return $products;
    }
207301
public function getPackageAssetsDirs($jsonData)
    {
        $packagesAssetsDir = null;
        // If some assets were set on the package
        if (isset($jsonData["extra"][self::LABEL_ASSETS_DIR])) {
            // We get the assets-dir of this package
            $packagesAssetsDir = $jsonData["extra"][self::LABEL_ASSETS_DIR];
            if (is_string($packagesAssetsDir)) {
                // If we get a string, it's the public shortcut so we uniform the return
                $packagesAssetsDir = array(self::LABEL_PUBLIC_DIR => $packagesAssetsDir);
            }
        }
        return $packagesAssetsDir;
    }
830516
public function add(array $product, array $data)
    {
        $result = array();
        $this->hook->attach('cart.add.product.before', $product, $data, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        $data += array(
            'quantity' => 1,
            'user_id' => $this->cart->getUid(),
            'store_id' => $product['store_id'],
            'product_id' => $product['product_id']
        );

        $data['cart_id'] = $this->set($data);

        if (empty($data['cart_id'])) {
            return $this->getResultError();
        }

        $result = $this->getResultAdded($data);
        $this->hook->attach('cart.add.product.after', $product, $data, $result, $this);
        return (array) $result;
    }
145553
private function getAffectedProductIds($category)
    {
        $oldPositionProductIds     = array_keys($this->saveHandler->getProductPositionsByCategory($category));
        $defaultPositionProductIds = [];
        $newPositionProductIds     = array_keys($category->getSortedProducts());

        $oldBlacklistedProductIds     = array_values($this->saveHandler->getProductBlacklistByCategory($category));
        $defaultBlacklistedProductIds = [];
        $newBlacklistedProductIds     = array_values($category->getBlacklistedProducts() ?? []);

        if (true === (bool) $category->getUseStorePositions()) {
            $defaultPositionProductIds = array_keys(
                $this->saveHandler->getProductPositions(
                    $category->getId(),
                    \Magento\Store\Model\Store::DEFAULT_STORE_ID
                )
            );

            $defaultBlacklistedProductIds = array_values(
                $this->saveHandler->getProductBlacklist(
                    $category->getId(),
                    \Magento\Store\Model\Store::DEFAULT_STORE_ID
                )
            );
        }

        $affectedProductIds = array_merge(
            $oldPositionProductIds,
            $defaultPositionProductIds,
            $newPositionProductIds,
            $oldBlacklistedProductIds,
            $defaultBlacklistedProductIds,
            $newBlacklistedProductIds
        );

        if ($category->getAffectedProductIds()) {
            $affectedProductIds = array_merge($affectedProductIds, $category->getAffectedProductIds());
        }

        return array_unique($affectedProductIds);
    }
1208964
private function addAttributeData($storeId, $productIds, $indexData = [])
    {
        foreach ($this->attributeIdsByTable as $backendTable => $attributeIds) {
            $attributesData = $this->loadAttributesRawData($storeId, $productIds, $backendTable, $attributeIds);
            foreach ($attributesData as $row) {
                $productId    = (int) $row['entity_id'];
                $attribute    = $this->attributesById[$row['attribute_id']];
                $indexValues  = $this->attributeHelper->prepareIndexValue($attribute, $storeId, $row['value']);
                if (!isset($indexData[$productId])) {
                    $indexData[$productId] = [];
                }

                $indexData[$productId] += $indexValues;

                $this->addIndexedAttribute($indexData[$productId], $attribute);
            }
        }

        return $indexData;
    }
44398
public function getCategoryUrls(string $category, array $criteria = [], $siteId = null): array
    {
        return RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId);
    }
312333
function productCategoriesString()
    {
        $categories = $this->attribute( 'product_categories' );
        if ( !$categories )
        {
            $result = ezpI18n::tr( 'kernel/shop', 'Any' );
            return $result;
        }

        $categoriesNames = array();
        foreach ( $categories as $cat )
            $categoriesNames[] = $cat['name'];

        return join( ', ', $categoriesNames );
    }
279707
protected function saveCategoryAttributes(array $attributesData)
    {
        $entityFieldName = 'entity_id';
        if ($this->categoryImportVersionFeature) {
            $entityFieldName = $this->categoryImportVersionFeature->getEntityFieldName();
        }

        $entityIds = array();

        foreach ($attributesData as $tableName => $data) {
            $tableData = [];

            foreach ($data as $entityId => $attributes) {
                $entityIds[] = $entityId;

                foreach ($attributes as $attributeId => $storeValues) {
                    foreach ($storeValues as $storeId => $storeValue) {
                        $tableData[] = [
                            $entityFieldName => $entityId,
                            'attribute_id' => $attributeId,
                            'store_id' => $storeId,
                            'value' => $storeValue
                        ];
                    }
                }
            }

            $this->_connection->insertOnDuplicate($tableName, $tableData, ['value']);
        }

        $entityIds = array_unique($entityIds);
        foreach ($entityIds as $entityId) {
            $this->reindexUpdatedCategories($entityId);
        }


        return $this;
    }
1002526
function productCategoriesIDs()
    {
        $catIDs = array();
        $categories = $this->attribute( 'product_categories' );

        if ( $categories )
        {
            foreach ( $categories as $cat )
                $catIDs[] = $cat['id'];
        }

        return $catIDs;
    }
107490
protected function saveProductCategories($data)
    {
        if (isset($data['category_id']) && count($data['category_id']) > 0) {
            $this->categories()->sync($data['category_id']);
        }
    }
1112721
protected function _getProductData(Product $product, ProductIterator $children)
    {
        $categoryIds = $this->categoryRepository->getCategoryIds($product);
        $productData = new IndexDocument(array(
            'id' => $product->getSolrId(), // primary identifier, must be unique
            'product_id' => $product->getId(),
            'category' => $categoryIds, // @todo get category ids from parent anchor categories as well
            'category_name_t_mv' => $this->categoryRepository->getCategoryNames($categoryIds, $product->getStoreId()),
            'store_id' => $product->getStoreId(),
            'content_type' => self::CONTENT_TYPE,
            'is_visible_in_catalog_i' => intval($product->isVisibleInCatalog()),
            'is_visible_in_search_i' => intval($product->isVisibleInSearch()),
            'has_special_price_i' => intval($product->hasSpecialPrice()),
            'is_in_stock_i' => intval($product->isInStock()),
        ));

        $this->_addBoostToProductData($product, $productData);

        $this->_addFacetsToProductData($product, $productData, $children);

        $this->_addSearchDataToProductData($product, $productData, $children);

        $this->_addSortingDataToProductData($product, $productData);

        $this->_addResultHtmlToProductData($product, $productData);

        $this->_addCategoryProductPositionsToProductData($product, $productData);

        $this->eventDispatcher->dispatch('integernet_solr_get_product_data', array(
            'product' => $product,
            'product_data' => $productData,
            'children' => $children,
        ));

        return $productData;
    }
1113278
public function deserialize(array $data, Category $category = null)
    {
        if (empty($category)) {
            $category = $this->categoryRepo->findOneBy(['id' => $data['id']]);
        }
        if (empty($category)) {
            $category = new Category();
        }
        if (isset($data['user'])) {
            $user = isset($data['user']['id']) ? $this->userRepo->findOneBy(['uuid' => $data['user']['id']]) : null;
            $category->setUser($user);
        }
        $this->addIfPropertyExists('name', 'setName', $data, $category);
        $this->addIfPropertyExists('order', 'setOrder', $data, $category);

        return $category;
    }
91669
public static function get_category_extensions($categories)
    {
        if (empty($categories)) {
            return array();
        }

        // Fix arguments into a single array
        if (!is_array($categories)) {
            $categories = array($categories);
        } elseif (count($categories) === 1 && is_array(reset($categories))) {
            $categories = reset($categories);
        }

        // Check configured categories
        $appCategories = static::config()->get('app_categories');

        // Merge all categories into list of extensions
        $extensions = array();
        foreach (array_filter($categories) as $category) {
            if (isset($appCategories[$category])) {
                $extensions = array_merge($extensions, $appCategories[$category]);
            } else {
                throw new InvalidArgumentException("Unknown file category: $category");
            }
        }
        $extensions = array_unique($extensions);
        sort($extensions);
        return $extensions;
    }
900473
public static function createCategory($data)
	{
		JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_categories/models');
		JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_categories/tables');

		$categoryModel = JModelLegacy::getInstance('Category', 'CategoriesModel', array('ignore_request' => true));
		$categoryModel->save($data);

		$catid = $categoryModel->getState('category.id');

		return $catid;
	}
119335
public function loadCategory($categoryId, \DmsLoaderParams $params)
  {
    $objCategory = $this->Database->prepare("SELECT * FROM tl_dms_categories WHERE id = ?")
                    ->limit(1)
                    ->execute($categoryId);
    
    $category = null;
    if ($objCategory->numRows)
    {
      $category = $this->buildCategory($objCategory);
      if ($params->loadAccessRights)
      {
        $category->accessRights = $this->getAccessRights($category, $params);
      }
      if ($params->loadDocuments)
      {
        $category->documents = $this->getDocuments($category, $params);
      }
      if ($params->loadRootCategory)
      {
        $category->parentCategory = $this->loadCategory($category->parentCategoryId, $params);
      }
    }

    return $category;
  }