Jump to content

tsprings

Members
  • Posts

    7
  • Joined

  • Last visited

Profile Information

  • Location
    Seattle
  • Interests
    Web dev, photography, music, sewing
  • Activity
    Developer

Recent Profile Visitors

352 profile views

tsprings's Achievements

Newbie

Newbie (1/14)

3

Reputation

  1. Based on this post: http://www.prestashop.com/forums/topic/61907-displaying-all-products-from-subcategories-on-the-category-page/page-3?do=findComment&comment=1278016 (Use at your own risk, this is working on my 1.6 store, but I am by no means a Prestashop expert.) Create the following file: override/controllers/front/CategoryController.php With this code: <?php class CategoryController extends CategoryControllerCore { public $php_self = 'category'; protected $category; public $customer_access = true; public $subCatProdCount = 0; /** * Assign sub categories templates vars */ protected function assignSubcategories() { if ($subCategories = $this->category->getSubCategories($this->context->language->id)) { $subcategory_objects=array(); foreach ($subCategories as $subcategory) { $sub=new Category(intval($subcategory['id_category']));//,intval($cookie->id_lang)); $subcategory_objects[$subcategory['id_category']]=$sub; $this->subCatProdCount += $sub->getProducts(null, null, null, $this->orderBy, $this->orderWay, true); } $this->context->smarty->assign("subcategories_objects",$subcategory_objects); $this->context->smarty->assign(array( 'subcategories' => $subCategories, 'subcategories_nb_total' => count($subCategories), 'subcategories_nb_half' => ceil(count($subCategories) / 2) )); } } public function assignProductList() { $hookExecuted = false; Hook::exec('actionProductListOverride', array( 'nbProducts' => &$this->nbProducts, 'catProducts' => &$this->cat_products, 'hookExecuted' => &$hookExecuted, )); // The hook was not executed, standard working if (!$hookExecuted) { $this->context->smarty->assign('categoryNameComplement', ''); $this->nbProducts = $this->category->getProducts(null, null, null, $this->orderBy, $this->orderWay, true); $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts" $this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); } // Hook executed, use the override else // Pagination must be call after "getProducts" $this->pagination($this->nbProducts); Hook::exec('actionProductListModifier', array( 'nb_products' => &$this->nbProducts, 'cat_products' => &$this->cat_products, )); foreach ($this->cat_products as &$product) if ($product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity'])) $product['minimal_quantity'] = $product['product_attribute_minimal_quantity']; $this->addColorsToProductList($this->cat_products); $this->nbProducts += $this->subCatProdCount; $this->context->smarty->assign('nb_products', $this->nbProducts); } } In the bootstrap theme, category.tpl find the following code: {if $products} <div class="content_sortPagiBar clearfix"> <div class="sortPagiBar clearfix"> {include file="./product-sort.tpl"} {include file="./nbr-product-page.tpl"} </div> <div class="top-pagination-content clearfix"> {include file="./product-compare.tpl"} {include file="$tpl_dir./pagination.tpl"} </div> </div> {include file="./product-list.tpl" products=$products} <div class="content_sortPagiBar"> <div class="bottom-pagination-content clearfix"> {include file="./product-compare.tpl" paginationId='bottom'} {include file="./pagination.tpl" paginationId='bottom'} </div> </div> {/if} And replace the {/if} with: {elseif isset($subcategories_objects)} {foreach from=$subcategories item=subcategory} {assign var="subcategory_id" value=$subcategory.id_category} {assign var="subcategory_object" value=$subcategories_objects.$subcategory_id} {include file="./product-list.tpl" products=$subcategory_object->getProducts('1','1','100','price','desc')} {/foreach} {/if} It's not perfect (as in you can't sort, compare, etc.) but at least you can view products in subcategories.
  2. Thanks Vekia. Perhaps I'm missing something. Doesn't that just affect what's displayed under that block? I have a site structure that's like: * Products * Parent Category * Child Category And I'd like my child category products to show up when I'm in my Parent Category and Products. Not just the categories in the block, but the actual products on the page when I'm viewing the category pages. Right now when I'm in Products, I see my categories and subcategories displaying in the block, but as for the actual product view I get "There are no products in this category" followed by a list of subcategories. I'd like to see all the products. I guess I may have to manually just add all my products to their parent categories...
  3. It may come to associating all products with their parent category as well, but I'd really like to avoid it (as I have a large number of products). Manually would take days, and trying to do it with straight sql is giving me a headache. Logically, a product that is in a subcategory would also be in the parent category. It boggles my mind why Prestashop wouldn't have a flag for this somewhere. (I'm hoping there is one that I have simply missed!) It appears I can also do some controller editing, but that seems sloppy. http://www.prestashop.com/forums/topic/61907-displaying-all-products-from-subcategories-on-the-category-page/page-3?do=findComment&comment=1278016
  4. This worked for me in 1.6. (Relative path rather than full url.)
  5. I am also interested in this. I initially tried this route and was disappointed to see that I cannot use combinations in conjunction with virtual products.
×
×
  • Create New...