Jump to content

Missing products from search


Recommended Posts

Hi Guys,

I've picked up a job at an ecommerce business, where their prestashop installation was developed by someone else. I am also new to prestashop.

There are a large number of products across our sites that don't appear in searches even when searching by the product reference. The last developer was aware of this and created a php script  (see below) which is meant to identify the missing links in the database.

Our prestashop instance has the storecommander module installed for managing products and all of the products were entered into the database using this module.

Here are the functions that identify the problems:

function check_category_shop_link($mysqli, $id_category, $id_shop){
    $query = "SELECT id_category, id_shop FROM "._DB_PREFIX_."category_shop WHERE id_category = '$id_category' AND id_shop = '$id_shop';";
    $result = simple_select($mysqli, $query);
    if ($result->num_rows == 1){
        return true;
    }
    else {
        return false;
    }
}


function check_product_category_link($mysqli, $product_results){
    $result = simple_select($mysqli, $product_results);
    $default_category_errors = "";
    $shop_category_errors = "";
    while ($product = $result->fetch_assoc()) {
        $id_product = $product['id_product'];
        $id_category_default = $product['id_category_default'];
        if(array_key_exists('id_shop', $product)){
            $id_shop = $product['id_shop'];
            if (check_category_shop_link($mysqli, $id_category_default, $id_shop) == false){
                $shop_category_errors .= "There's a problem with this product's ($id_product) category ($id_category_default). It's not in the right shop ($id_shop)!<br/>";
            }
        }
        else{
            $id_shop = "n/a";
        }
        $check_category_sql = "SELECT * FROM "._DB_PREFIX_."category_product WHERE id_product = $id_product AND id_category = $id_category_default";
        $this_product_category_check = simple_select($mysqli, $check_category_sql);
        if ($this_product_category_check->num_rows != 1){
            $default_category_errors .= "Error with, $id_product, Default Category, $id_category_default, in shop, $id_shop, it has, " . $this_product_category_check->num_rows . ", links to the default category.<br/>";
        }
    }
    return $default_category_errors . $shop_category_errors;
}

My first reaction to this was to do the opposite of the above code and add the links in manually. I did this and the product still doesn't appear. 

Any ideas?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...