I installed a multivendor module on opencard 2, which does not have the ability to display all sellers and their products on the site itself (not the admin panel), it is not possible to look at the card of any seller and what products he has. I managed to do so that the brief information about the seller was displayed in the product card, which he added, it turned out to make a separate seller page with information about him, now on this page you need to display all of his goods.
For this you need to use three tables:
- the first
vendorstores fields withvendorid and product id, - second
producttable withproductdata - and in the third table
product_descriptionyou only need to select the product name.
One vendor from the vendor table can have, for example, three products with the corresponding id, and you need to take these id's out of the product data from the product and product_description tables and write all this data into one array so that you can output all the goods of this seller on his page in a cycle .
what i did ...
$vproducts = array(); $sql_products_data = array(); for ($i = 0; $i < $count_id; $i++) { $sql_products_data[] = $this->db->query("select product_id, image, price, name from " . DB_PREFIX . "product, " . DB_PREFIX . "product_description where " . DB_PREFIX . "product_description.product_id = " . $query['vproduct_id'] . " and " . DB_PREFIX . "product.product_id = " . $query['vproduct_id']); } foreach ($sql_products_data as $result) { if ($result) { $vproducts['prod_id'] = $result['product_id']; $vproducts['prod_image'] = $result['image']; $vproducts['prod_price'] = $result['price']; $vproducts['prod_name'] = $result['name']; } } if ($vendor_products) { foreach ($vendor_products as $result) { $data['products_list_vendor']['vproduct_id'] = $result['prod_id']; $data['products_list_vendor']['vproduct_image'] = $result['prod_image']; $data['products_list_vendor']['vproduct_price'] = $result['prod_price']; $data['products_list_vendor']['vproduct_name'] = $result['prod_name']; } } <div id="vendor_products"> <?php forech($products_list_vendor as $products_list) { ?> <p><?php echo $products_list['vproduct_id']; ?></p> <p>- - - - - - - - - -</p> <?php } ?> </div>