Post by roylepython » Mon Sep 30, 2013 8:44 pm

As the title says im trying to find a way to add the Categories that have been selected by the user to the get the narrowed list of products shared across the categories added to the cart and invoice to make stock control and selection easier

Ive used http://forum.opencart.com/viewtopic.php?t=45907 although i get a returned error

Notice: Error: Unknown column 'pd.name' in 'order clause'
Error No: 1054
SELECT * FROM kbb_category c LEFT JOIN kbb_category_description cd ON (cd.category_id = c.category_id) LEFT JOIN kbb_product_to_category p2c ON (p2c.category_id = cd.category_id) LEFT JOIN `kbb_category_to_store` c2s ON (c2s.`category_id` = p2c.`category_id`) WHERE cd.language_id = '1' AND p2c.product_id = '161' AND c2s.`store_id` = '0' ORDER BY pd.name ASC in /var/zpanel/hostdata/zadmin/public_html/*****/system/database/mysql.php on line 50

when navigating to Sales >> Orders >> Edit

im also trying to understand how i can add the catagories to the invoice and the cart to save multiplication of products as the catagories have gone into the thousands with the 1 parent limit the catagories narrow selection down by design and colour

Forgot to mention i'm using version 1.5.5.1 with php version mysql 5.1 and php 5.3.3

New member

Posts

Joined
Wed Sep 18, 2013 5:18 am

Post by roylepython » Tue Oct 01, 2013 7:30 pm

Cmon surely someone has sone idea how to fix this ???

New member

Posts

Joined
Wed Sep 18, 2013 5:18 am

Post by roylepython » Wed Oct 02, 2013 6:43 pm

Anybody? Surely someone has had need of this type of thing before

website type: Kitchen Doors

short recap products shared in 10 categories (the products is the size with the model number)

the categories are the color and design.

The color and design need to be carried into the product that the user has selected.

so simply put if the server has gone to big and red those would be somewhere within the product on the invoice admin and client side.

Note: I am willing to discuss custom modification (and pricing accordingly) on this respect from a developer of mods. as im dealing with for a client im aware that this is a bespoke feature if a vqmod can be created for it given the VPS this site is held on i maintain its server side at a root level.

New member

Posts

Joined
Wed Sep 18, 2013 5:18 am

Post by roylepython » Fri Oct 04, 2013 2:19 am

Anybody??

New member

Posts

Joined
Wed Sep 18, 2013 5:18 am

Post by blindjoedeath » Fri Oct 04, 2013 3:59 am

Just brainstorming. You may want to experiment with an extension like this: http://www.opencart.com/index.php?route ... lds&page=1. (That' mod isn't mine, but I'm considering purchasing it for similar purposes.)

On the cart page (and the invoice), you'd want to render the custom fields similar to the way options are listed. So - "color:red" and "size:big" would show there.

If you don't want to purchase an extension, you may want to try stuffing your values in attributes, and doing the same thing.

My Opencart Extensions
My site for installed home products: Home - Windows - Water Heaters -
Furnaces - and more!


Newbie

Posts

Joined
Fri Jul 19, 2013 2:17 am

Post by roylepython » Fri Oct 04, 2013 4:11 am

awesome idea although that would be a problem as there shared over categories unless of course the field could be populated by categories which have been selected on the route to the product

given i have 15000 categories (4 deep in places) 20 designs with 33 color variations the i need a way to figure which route the customer took to it

New member

Posts

Joined
Wed Sep 18, 2013 5:18 am

Post by roylepython » Mon Oct 07, 2013 5:32 pm

Wow surely somone can think of a solution to this! even as a custom bespoke module!

As far as ive got so far.
Re: Adding the category to invoices

Postby straightlight » Wed Nov 23, 2011 8:50 pm
Simply by reversing psychology, when we can't get a product by categories, we have to get a category by products. ;)

In admin/controller/sale/order.php file,

Find:

Code: Select all
$this->data['column_model'] = $this->language->get('column_model');



add above:

Code: Select all
$this->data['column_category'] = $this->language->get('column_category');



Then, find:

Code: Select all
$this->data['order_products'][]



add above:

Code: Select all
$category_info = $this->model_catalog_product->getCategoriesByProduct($order_product['product_id']);

if ($category_info) {
$this->data['category_info'] = array();
foreach ($category_info as $cat_info) {
$this->data['category_info'][] = array(
'product_id' => (int)$cat_info['product_id'],
'name' => $cat_info['name'],
);
}
}



In admin/model/catalog/product.php file,

Find:

Code: Select all
public function getProductsByCategoryId($category_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.category_id = '" . (int)$category_id . "' ORDER BY pd.name ASC");

return $query->rows;
}



Add above:

Code: Select all
public function getCategoriesByProduct($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (cd.category_id = c.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (c.category_id = p2c.category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.product_id = '" . (int)$product_id . "' ORDER BY pd.name ASC");

return $query->rows;
}



Of course, this is a quick way of doing it while a separate model file could be built in order to adapt it into the controller file.

In admin/view/template/sale/order_form.tpl file,

find:

Code: Select all
<td class="left"><?php echo $column_model; ?></td>



Add above:

Code: Select all
<td class="left"><?php echo $column_category; ?></td>



Then, find:

Code: Select all
<td class="left"><?php echo $order_product['name']; ?><br />



add below (NOT above):

Code: Select all
<?php foreach ($category_info as $cat_info) { ?>
<?php if ((int)$order_product['product_id'] == (int)$cat_info['product_id']) { ?>
<td class="left"><?php echo $cat_info['name']; ?><br />
<?php } ?>
<?php } ?>



In admin/language/english/sale/order.php file,

find:

Code: Select all
$_['column_model'] = 'Model';



add above:

Code: Select all
$_['column_category'] = 'Categories';



All set.
Regards,
Straightlight
problem is i hit the sql error code above... the tables are there im wondering if its a santax error in the change of versions to mysql

New member

Posts

Joined
Wed Sep 18, 2013 5:18 am

Post by ajaxmint » Sat Oct 19, 2013 1:56 am

Please try to replace product.php function with Below function

Code: Select all

public function getCategoriesByProduct($product_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c 
			LEFT JOIN " . DB_PREFIX . "category_description cd ON (cd.category_id = c.category_id) 
			LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (c.category_id = p2c.category_id)
			WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' 
			AND p2c.product_id = '" . (int)$product_id . "' ORDER BY cd.name ASC");

		return $query->rows;
	}

OpenCart Development | Ajaxmint Gallery


Newbie

Posts

Joined
Thu Oct 17, 2013 2:29 am
Who is online

Users browsing this forum: No registered users and 12 guests