• Resolved IndikatorDesign

    (@indikatordesign)


    Hello,

    I have made some changes to the WooCommerce Index so that it better fits my needs. It worked pretty well for a long time, but now I get a weird error.

    First, it works fine when my customizing is disabled. But maybe you can give me a hint. I have not found anything useful by searching with Google.

    I use the initial query to get the posts with my customized index-template. With “$query->set()” I do some small modifications like changing ‘posts_per_page’..

    But it creates a duplicated alias ‘price_query’ when I filter the posts by price. Works well with all other filter options, and it works also well with the Woo-Widgets.

    Any idea how I can fix this?

    Thank you and best regards

    [18-Aug-2017 10:38:22 UTC] WordPress database error Not unique table/alias: 'price_query' for query SELECT SQL_CALC_FOUND_ROWS  preffix_posts.ID FROM preffix_posts  INNER JOIN ( SELECT post_id, max( meta_value+0 ) price FROM preffix_postmeta WHERE meta_key='_price' GROUP BY post_id ) as price_query ON preffix_posts.ID = price_query.post_id  INNER JOIN ( SELECT post_id, max( meta_value+0 ) price FROM preffix_postmeta WHERE meta_key='_price' GROUP BY post_id ) as price_query ON preffix_posts.ID = price_query.post_id  WHERE 1=1  AND (
      preffix_posts.ID NOT IN (
    				SELECT object_id
    				FROM preffix_term_relationships
    				WHERE term_taxonomy_id IN (49)
    			)
    ) AND preffix_posts.post_type = 'product' AND ((preffix_posts.post_status = 'publish')) GROUP BY preffix_posts.ID ORDER BY  price_query.price DESC  LIMIT 0, 6 made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts
Viewing 1 replies (of 1 total)
  • Thread Starter IndikatorDesign

    (@indikatordesign)

    Solved the problem. I created a new WC_Query object to get the query vars for following Ajax-Requests.

    But you can simply use ‘WC()->query->get_catalog_ordering_args()’ instead.

Viewing 1 replies (of 1 total)

The topic ‘Database query duplicated alias’ is closed to new replies.