Post by aaron1988 » Thu Apr 07, 2011 10:30 pm

Hi people,

I wondered if someone knows how to add Related Products to the csv improt pro module? as i see in the module it has things like:

Code: Select all

$product['product_related'] = $this->model_catalog_product->getProductRelated($update_id);
but there is nothing actually inlucding it into the import as i need it exactly the same as additional images so you can include more than one column.

Hope someone can help

Regards,
Aaron

Active Member

Posts

Joined
Thu Jan 27, 2011 10:03 am

Post by aaron1988 » Mon Apr 11, 2011 4:52 am

Bump - Does anybody have a clue how to do this :( please help

Thanks
Aaron

Active Member

Posts

Joined
Thu Jan 27, 2011 10:03 am

Post by traceofwind » Tue Apr 12, 2011 6:43 am

Hi Aaron,

I did look into this but had to abandon due to other priorities. Hopefully this thread can generate a solution! I noted some juicy bits of code for you from the model folders, which the /admin/controller/tool/csv_import.php does have access to. On a positive note, as you pointed out, csv_import.php admin controller does have a line of code for product_related... so perhaps all that is necessary is to supply the data -in the correct syntax?

/admin/model/product.php (search for 'product_related'):

Code: Select all

if (isset($data['product_related'])) {
			foreach ($data['product_related'] as $related_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
			}
		}
/admin/model/tool/csv_import.php

Code: Select all

$query = $this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_related");
All the best,

Gary

New member

Posts

Joined
Fri Jul 02, 2010 6:37 am

Post by aaron1988 » Tue Apr 12, 2011 4:02 pm

Cheers for that Gary i will look into it but now the part which gets me is? how do i add it to the csv_import.tpl file :) same style as Additional Images, as i not sure if i added it right or not lol

All the best

Aaron

Active Member

Posts

Joined
Thu Jan 27, 2011 10:03 am

Post by aaron1988 » Wed Apr 13, 2011 5:12 am

Hey seemed to of fixed the Related Products i paid someone to help £50 :). so i wont publish here hehe but for the Size and Gender i will post tomorrow just been so busy.

Regards,
Aaron

Active Member

Posts

Joined
Thu Jan 27, 2011 10:03 am

Post by traceofwind » Wed Apr 13, 2011 8:29 pm

Sent you a PM ;)

New member

Posts

Joined
Fri Jul 02, 2010 6:37 am

Post by farez » Sat Oct 08, 2011 5:31 am

if you get the product id, then justs set this variable before addProduct is called

$product['product_related'][$this->data['csv_import_language']] = '57';
before this line : $this->model_catalog_product->addProduct($product);

btw you can get product id by querying the name using:
$testy = $this->model_tool_csv_import->getProductId('name', 'Domestic Safes');


//edit, if you want to pass more than 1
$product['product_related'][0]= '57';
$product['product_related'][1] = '56';
$product['product_related'][3] = '95';

Newbie

Posts

Joined
Fri Oct 07, 2011 12:36 am
Who is online

Users browsing this forum: No registered users and 2 guests