Manufacturer Details page
On the Manufacturer Details page you can display a manufacturer name, description and other details. Also this page can contain a list of manufacturer's products.
Start with creating a new page and assign some name and URL to it. On the Actions tab select the shop:manufacturer action. This action loads a manufacturer by its URL name specified in the first segment of the page URL. In the previous article we demonstrated how to output a list of manufacturers with links.
The shop:manufacturer action creates the $manufacturer variable which is an instance of the Shop_Manufacturer class. If a requested manufacturer is not found, this variable can have the NULL value. The following code outputs a manufacturer's name, description and a list of its products.
<? if ($manufacturer): ?> <h2>Products by <?= h($manufacturer->name) ?></h2> <?= $manufacturer->description ?> <? $this->render_partial('shop:product_list', array( 'products'=>$manufacturer->list_products(), 'records_per_page'=>2, 'paginate'=>true, 'pagination_base_url'=>root_url('/manufacturer/'.$manufacturer->url_name), 'page_index'=>$this->request_param(1, 0) )); ?> <? else: ?> <p>Manufacturer not found</p> <? endif ?>
The first line of the code checks whether the manufacturer object is found. If so, the code outputs the page header, which contains the manufacturer. For displaying a list of products we used the shop:products partial which is described in the Displaying a list of products article.
Please note how the pagination is configured. The base pagination URL includes the /manufacturer part. You should change this part if an URL of your manufacturer's details page is not /manufacturer.
Next: Tips and Tricks
Previous: Manufacturer List page
Return to Building your online store
Comments
No comments posted so far.
Add your comment
Loading form...