Jump to content

Edit History

4presta

4presta

private function formatCategory($rawCategory, $idsOfCategoriesInPath): array
    {
        $children = [];
        if (!empty($rawCategory['children'])) {
            foreach ($rawCategory['children'] as $k => $v) {
                $children[$k] = $this->formatCategory($v, $idsOfCategoriesInPath);
            }
        }

        $categoriesArray = '';
        if ($rawCategory['id_category'] == 12) {
            $categoriesArray = array(
                'id' => $rawCategory['id_category'],
                'link' => 'https://www.motorola.com',
                'name' => $rawCategory['name'],
                'desc' => $rawCategory['description'],
                'children' => $children,
                'in_path' => in_array($rawCategory['id_category'], $idsOfCategoriesInPath),
            );    
        } elseif  ($rawCategory['id_category'] == 13) {
            $categoriesArray = array(
                'id' => $rawCategory['id_category'],
                'link' => 'https://www.nokia.com',
                'name' => $rawCategory['name'],
                'desc' => $rawCategory['description'],
                'children' => $children,
                'in_path' => in_array($rawCategory['id_category'], $idsOfCategoriesInPath),
            );    
        } else {
            $categoriesArray = array(
                'id' => $rawCategory['id_category'],
                'link' => $this->context->link->getCategoryLink($rawCategory['id_category'], $rawCategory['link_rewrite']),
                'name' => $rawCategory['name'],
                'desc' => $rawCategory['description'],
                'children' => $children,
                'in_path' => in_array($rawCategory['id_category'], $idsOfCategoriesInPath),
            );   
        }

        return $categoriesArray;

        /*return [
            'id' => $rawCategory['id_category'],
            'link' => $this->context->link->getCategoryLink($rawCategory['id_category'], $rawCategory['link_rewrite']),
            'name' => $rawCategory['name'],
            'desc' => $rawCategory['description'],
            'children' => $children,
            'in_path' => in_array($rawCategory['id_category'], $idsOfCategoriesInPath),
        ];*/
    }

It would definitely be a good idea to create an override and add your own hook to the functions. Then create a small module that would return your own URL via the hook.

4presta

4presta

private function formatCategory($rawCategory, $idsOfCategoriesInPath): array
    {
        $children = [];
        if (!empty($rawCategory['children'])) {
            foreach ($rawCategory['children'] as $k => $v) {
                $children[$k] = $this->formatCategory($v, $idsOfCategoriesInPath);
            }
        }

        $categoriesArray = '';
        if ($rawCategory['id_category'] == 12) {
            $categoriesArray = array(
                'id' => $rawCategory['id_category'],
                'link' => 'https://www.motorola.com',
                'name' => $rawCategory['name'],
                'desc' => $rawCategory['description'],
                'children' => $children,
                'in_path' => in_array($rawCategory['id_category'], $idsOfCategoriesInPath),
            );    
        } elseif  ($rawCategory['id_category'] == 13) {
            $categoriesArray = array(
                'id' => $rawCategory['id_category'],
                'link' => 'https://www.nokia.com',
                'name' => $rawCategory['name'],
                'desc' => $rawCategory['description'],
                'children' => $children,
                'in_path' => in_array($rawCategory['id_category'], $idsOfCategoriesInPath),
            );    
        } else {
            $categoriesArray = array(
                'id' => $rawCategory['id_category'],
                'link' => $this->context->link->getCategoryLink($rawCategory['id_category'], $rawCategory['link_rewrite']),
                'name' => $rawCategory['name'],
                'desc' => $rawCategory['description'],
                'children' => $children,
                'in_path' => in_array($rawCategory['id_category'], $idsOfCategoriesInPath),
            );   
        }

        return $categoriesArray;

        /*return [
            'id' => $rawCategory['id_category'],
            'link' => $this->context->link->getCategoryLink($rawCategory['id_category'], $rawCategory['link_rewrite']),
            'name' => $rawCategory['name'],
            'desc' => $rawCategory['description'],
            'children' => $children,
            'in_path' => in_array($rawCategory['id_category'], $idsOfCategoriesInPath),
        ];*/
    }

 

×
×
  • Create New...