Tuesday, 15 June 2010

php - How do i show all product info in opencart module? -



php - How do i show all product info in opencart module? -

i'm new opencart , created module latest module in opencart difference latest module show latest product , module product , showing product in random manner. module working fine..but there problem occurs show actual rating each product..now want add together rating scheme in module. want know whta should right query of mysql product info name,description,reviews,ratings,product_id etc..

you haven't shown approach general pointers

first load product.php model in controller file $this->load->model('catalog/product');

then decide filters when calling getproducts if don't give filters homecoming products in database, lets decide no filters pass empty array of info (or don't pass @ )

$data = array();

then phone call function

$results = $this->model_catalog_product->getproducts($data); //or without $data

now can like

foreach ($results $result) { $this->data['products'][] = array( 'product_id' => $result['product_id'], 'name' => $result['name'], 'rating' => $result['rating'], );

now can utilize in tpl file like

<?php foreach ($products $product) { ?> code here <?php echo $product['rating']; ?> <?php } ?>

this generic way should use, , easy too, if know how getproducts function takes info out database , homecoming result see getproducts function in catalog/model/catalog/product.php

php opencart

No comments:

Post a Comment