if you remove the id_country = 21
SELECT p.id_product, p.price, psi.price_min, psi.price_max FROM (SELECT p.id_product, p.id_manufacturer, sa.quantity, p.condition, p.weight, p.price FROM ps_product p
LEFT JOIN ps_stock_available sa ON (p.id_product=sa.id_product AND 0 = sa.id_product_attribute AND sa.id_shop = 1 AND sa.id_shop_group = 0 )
INNER JOIN ps_category_product cp ON (p.id_product = cp.id_product) INNER JOIN ps_category c ON (cp.id_category = c.id_category AND c.active=1)
INNER JOIN ps_product_shop ps ON (p.id_product = ps.id_product AND ps.id_shop = 1) WHERE p.visibility IN ('both', 'catalog')
AND c.nleft>=3
AND c.nright<=50
AND ps.id_shop='1'
AND p.active = TRUE GROUP BY p.id_product) p
INNER JOIN ps_layered_price_index psi ON (psi.id_product = p.id_product AND psi.id_currency = 1)
GROUP BY p.id_product ORDER BY psi.price_min ASC LIMIT 0, 39
the request work fine but i need to understad your needs
if you need to add the country condition in your request you can get it from the ps_shop_country table and i can add it to your request