Sometimes the related products I have added to a product seem to dissappear after a new edit on the product. A dump of the variable of related products taught me that the product_id of the products is NULL in the array, the product name DOES get found.
The product id and name of related products are fetched by the getProducts function, which has the following query
now this query does not seem to be in very good order, for example the distinct looks not in the correct place to me, and product_id is ambiguous (both in product and product_description, so gets returned twice) With multilanguage turned on the subquery returns more rows, I also get this error when running the query directly on the db.
Code: Select all
SELECT DISTINCT *, (SELECT keyword FROM " . DB_PREFIX . "url_alias WHERE query = 'product_id=" . (int)$product_id . "') AS keyword FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'"
Now what I have found is that I have this problem ONLY with products I have imported with an import script. Products manually added to the store don't have this problem. So my conclusion would be that I forget to add some information to a table on the import. But the weird part is that all the information for the getProducts query is there, but it just returns NULL for product_id.