2013-06-27 34 views

回答

8
taxon_products = current_taxon.products 
children_products = current_taxon.children.includes(:products).map(&:products). 
            flatten.compact.uniq 
1

通過@PinnyM答案是好的,如果你只需要搜索的一個孩子的水平,但如果你想找到所有產品分類單元下,你可以使用the in_taxon scope這樣的:

children_products = Spree::Product.in_taxon(current_taxon)