Exemple #1
0
 function sitemap()
 {
     $map = [];
     $zeroItems = \Ecommerce\Item::getList(['where' => ['category_id', 0]]);
     foreach ($zeroItems as $item) {
         $map[] = ['name' => $item->name, 'url' => ['loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . $item->getHref()]];
     }
     $categorys = \Ecommerce\Category::getList(['where' => ['parent_id', 0]]);
     $scan = function ($category, $scan) {
         $map = [];
         foreach ($category->items as $item) {
             $map[] = ['name' => $item->name, 'url' => ['loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . $item->getHref()]];
         }
         foreach ($category->catalogs as $child) {
             $map = array_merge($map, $scan($child, $scan));
         }
         return $map;
     };
     foreach ($categorys as $category) {
         $map = array_merge($map, $scan($category, $scan));
     }
     return $map;
 }