<?php

chdir('../../common');
require_once 'init.php';
chdir('../database');
require_once 'storeFrontend.php';
require_once 'storeAccount.php';
//require_once('plataform.php');
chdir('../pages/store');
if (!isset($_GET["store"]) or !storeExists($_GET["store"])) {
    header("Location: ../index.php");
}
// Update paths
function updatePath($elem)
{
    if ($elem["filename"] != 'imageurl') {
        $elem["file"] = "../../files/" . $elem["file"];
    }
    return $elem;
}
/* BEGIN -- Get store data */
$domain = $_GET["store"];
$storeId = getStoreId($domain);
// Logo
$logoPath = getStoreLogo($domain);
// Categories
$categories = getCategories($storeId);
// Products
$searchTerm = $_GET["terms"];
$products = searchOnStore($storeId, $searchTerm, 30);
$products = array_map("updatePath", $products);
<?php

chdir('../../common');
require_once 'init.php';
chdir('../database');
require_once 'storeFrontend.php';
require_once 'plataform.php';
chdir('../pages/store');
if (!isset($_GET["store"]) or !storeExists($_GET["store"]) or !isset($_GET["categoryid"])) {
    header("Location: ../index.php");
}
// Update paths
function updatePath($elem)
{
    if ($elem["filename"] != 'imageurl') {
        $elem["file"] = "../../files/" . $elem["file"];
    }
    return $elem;
}
/* BEGIN -- Get store data */
$domain = $_GET["store"];
$storeId = getStoreId($domain);
// Vat
$vat_oux = getStoreById($storeId);
$vat = $vat_oux[0]["vat"];
// Logo
$logoPath = getStoreLogo($domain);
// Categories
$categories = getCategories($storeId);
// Products
$products = getProductsOfCategory($_GET["categoryid"]);