I found the error. The field "ordering" in table "_phocacart_product_categories" was in most cases 0 (zero). I have now changed the zeros in the database table _phocacart_product_categories against 1,2,3, ...
Now the ordering is working.
The field "category_id" & "ordering" must be unique in the whole table. Double entries cause problems. I try to find the problem, why the entries in "ordering" were duplicate.
Item View (Product View) - Next/Previous Title - Buttons in the product display do not work properly
-
- Phoca Enthusiast
- Posts: 58
- Joined: 19 Nov 2008, 12:12
-
- Phoca Enthusiast
- Posts: 58
- Joined: 19 Nov 2008, 12:12
Re: Item View (Product View) - Next/Previous Title - Buttons in the product display do not work properly
Database procedure to re-order the categories in table "___phocacart_product_categories" according to the alias (in my case for alphabetical order) ASC.
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE new_ordering INT DEFAULT 0;
DECLARE prod_id INT DEFAULT 0;
DECLARE cat_id INT DEFAULT 0;
DECLARE last_category_id INT DEFAULT 0;
DECLARE cur1 CURSOR FOR SELECT ___phocacart_product_categories.product_id, ___phocacart_product_categories.category_id
FROM ___phocacart_product_categories
INNER JOIN ___phocacart_products ON ___phocacart_products.id = ___phocacart_product_categories.product_id
ORDER BY ___phocacart_product_categories.category_id ASC, ___phocacart_products.alias ASC;
OPEN cur1;
REPEAT
BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
FETCH cur1 INTO prod_id, cat_id;
IF NOT done THEN
IF cat_id = last_category_id THEN
SET new_ordering = new_ordering + 1;
UPDATE ___phocacart_product_categories
SET ordering = new_ordering
WHERE product_id = prod_id
AND category_id = cat_id;
ELSE
SET new_ordering = 1;
SET last_category_id = cat_id;
UPDATE ___phocacart_product_categories
SET ordering = new_ordering
WHERE product_id = prod_id
AND category_id = cat_id;
END IF;
END IF;
END;
UNTIL done END REPEAT;
CLOSE cur1;
END
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE new_ordering INT DEFAULT 0;
DECLARE prod_id INT DEFAULT 0;
DECLARE cat_id INT DEFAULT 0;
DECLARE last_category_id INT DEFAULT 0;
DECLARE cur1 CURSOR FOR SELECT ___phocacart_product_categories.product_id, ___phocacart_product_categories.category_id
FROM ___phocacart_product_categories
INNER JOIN ___phocacart_products ON ___phocacart_products.id = ___phocacart_product_categories.product_id
ORDER BY ___phocacart_product_categories.category_id ASC, ___phocacart_products.alias ASC;
OPEN cur1;
REPEAT
BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
FETCH cur1 INTO prod_id, cat_id;
IF NOT done THEN
IF cat_id = last_category_id THEN
SET new_ordering = new_ordering + 1;
UPDATE ___phocacart_product_categories
SET ordering = new_ordering
WHERE product_id = prod_id
AND category_id = cat_id;
ELSE
SET new_ordering = 1;
SET last_category_id = cat_id;
UPDATE ___phocacart_product_categories
SET ordering = new_ordering
WHERE product_id = prod_id
AND category_id = cat_id;
END IF;
END IF;
END;
UNTIL done END REPEAT;
CLOSE cur1;
END