<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
        xmlns:xhtml="http://www.w3.org/1999/xhtml" 
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" 
        xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
    
    <!-- Homepage - Highest priority -->
    <url>
        <loc>https://genexmart.com/</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>
    
    <!-- Static Pages -->
    <url>
        <loc>https://genexmart.com/about_us.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://genexmart.com/contact.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://genexmart.com/privacy_policy.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    <url>
        <loc>https://genexmart.com/Terms&amp;Conditions.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    <url>
        <loc>https://genexmart.com/Shipping&amp;Delivery.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    <url>
        <loc>https://genexmart.com/Cancellation&amp;RefundPolicy.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    <url>
        <loc>https://genexmart.com/faqs.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    
    <!-- Category Pages -->
    <?php
    // Connect to your database
    require('connection.inc.php');
    
    // Get all active categories
    $categories = mysqli_query($con, "SELECT id, categories FROM categories WHERE status=1");
    while($cat = mysqli_fetch_assoc($categories)) {
        echo '<url>
            <loc>https://genexmart.com/categories.php?id='.$cat['id'].'</loc>
            <lastmod>'.date('Y-m-d').'</lastmod>
            <changefreq>weekly</changefreq>
            <priority>0.9</priority>
        </url>';
        
        // Get subcategories for each category
        $subcategories = mysqli_query($con, "SELECT id, sub_categories FROM sub_categories WHERE status=1 AND categories_id=".$cat['id']);
        while($subcat = mysqli_fetch_assoc($subcategories)) {
            echo '<url>
                <loc>https://genexmart.com/sub_categories.php?id='.$subcat['id'].'</loc>
                <lastmod>'.date('Y-m-d').'</lastmod>
                <changefreq>weekly</changefreq>
                <priority>0.8</priority>
            </url>';
            
            // Get sub-subcategories if they exist
            $subsubcategories = mysqli_query($con, "SELECT id, sub_categories1 FROM sub_categories1 WHERE status=1 AND sub_categories_id=".$subcat['id']);
            while($subsubcat = mysqli_fetch_assoc($subsubcategories)) {
                echo '<url>
                    <loc>https://genexmart.com/sub_categories1.php?id='.$subsubcat['id'].'</loc>
                    <lastmod>'.date('Y-m-d').'</lastmod>
                    <changefreq>weekly</changefreq>
                    <priority>0.7</priority>
                </url>';
            }
        }
    }
    ?>
    
    <!-- Product Pages -->
    <?php
    // Get all active products with their variants
    $products = mysqli_query($con, "SELECT p.id, p.name, p.meta_title, p.meta_desc, p.meta_keyword, 
                                   pa.id as variant_id, pa.product_name, pa.mrp, pa.price, 
                                   (SELECT pi.product_images FROM product_images pi 
                                    WHERE pi.product_attr_id = pa.id 
                                    ORDER BY pi.image_order ASC LIMIT 1) as product_images
                                   FROM product p
                                   JOIN product_attributes pa ON p.id = pa.product_id
                                   WHERE p.status=1");
    
    while($product = mysqli_fetch_assoc($products)) {
        $lastmod = date('Y-m-d'); // You might want to use actual product modification date
        $imagePath = PRODUCT_MULTIPLE_IMAGE_SITE_PATH.$product['product_images'];
        $productName = htmlspecialchars($product['product_name']);
        
        echo '<url>
            <loc>https://genexmart.com/product.php?id='.$product['id'].'&amp;variant='.$product['variant_id'].'</loc>
            <lastmod>'.$lastmod.'</lastmod>
            <changefreq>weekly</changefreq>
            <priority>0.8</priority>
            <image:image>
                <image:loc>'.$imagePath.'</image:loc>
                <image:title>'.$productName.'</image:title>
                <image:caption>'.$productName.' available at GenexMart</image:caption>
            </image:image>
        </url>';
    }
    ?>
    
    <!-- Blog Pages (if you have them) -->
    <url>
        <loc>https://genexmart.com/blog.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.6</priority>
    </url>
    
    <!-- Other Important Pages -->
    <url>
        <loc>https://genexmart.com/login.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.5</priority>
    </url>
    <url>
        <loc>https://genexmart.com/register.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.5</priority>
    </url>
    <url>
        <loc>https://genexmart.com/forgot_password.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.3</priority>
    </url>
    <url>
        <loc>https://genexmart.com/cart.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.7</priority>
    </url>
    <url>
        <loc>https://genexmart.com/checkout.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.7</priority>
    </url>
    <url>
        <loc>https://genexmart.com/wishlist.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.6</priority>
    </url>
    <url>
        <loc>https://genexmart.com/my_account.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.6</priority>
    </url>
    <url>
        <loc>https://genexmart.com/my_order.php</loc>
        <lastmod>2023-12-15</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.6</priority>
    </url>
    
</urlset>