CSV Export - Characteristics Field Empty

  • Posts: 18
  • Thank you received: 0
10 years 4 months ago #164856

I am trying to create a mass action that runs each day to create a .csv of all our products, I can get the csv out but we have a characteristic called bottle size and although all the products and their variants(characteristics) are exported the field Bottle Size is blank how can I get the bottle size associated to the variant to display in this field?

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 4 months ago #164862

Hi,

Thanks for the report, it seems that some errors were presents.
We have corrected it on our end, and the fix will be available in the next release.

To correct it now, thanks to edit the file "administrator/components/com_hikashop/classes/massaction.php" and replace the function "organizeExportXolumn()" by:

	function organizeExportColumn($data,$table,&$elements,&$action,&$types){
		switch($data){
			case 'product':
				switch($table){
					case 'product':
						$ids = array();
						$database = JFactory::getDBO();
						foreach($elements as $element){
							if(isset($element->product_parent_id->id)){
								$ids[] = $element->product_parent_id->id;
							}else if($element->product_parent_id){
								$ids[] = $element->product_parent_id;
							}
						}
						if(!empty($ids)){

							$tIds = array();
							foreach($ids as $id){
								if(isset($id->id))
									$tIds[$id->id] = $id->id;
								elseif($id != 0)
									$tIds[$id] = $id;
							}

							$query = 'SELECT product_id, product_code';
							$query .= ' FROM '.hikashop_table('product');
							$query .= ' WHERE product_id IN ('.implode(',',$tIds).')';
							$database->setQuery($query);
							$rows = $database->loadObjectList();
							foreach($elements as $element){
								$id = $element->product_parent_id;
								$element->product_parent_id = '';
								$types['product_parent_id']->type = 'text';
								foreach($rows as $row){
									if($id->id != $row->product_id){continue;}
									$element->product_parent_id = $row->product_code;
								}
							}
						}
						break;
					case 'related':
						$ids = array();
						$database = JFactory::getDBO();
						foreach($elements as $element){
							$ids[] = $element->product_id;
						}
						$query = 'SELECT pr.product_id, p.product_code';
						$query .= ' FROM '.hikashop_table('product').' AS p';
						$query .= ' INNER JOIN '.hikashop_table('product_related').' AS pr ON pr.product_related_id = p.product_id';
						$query .= ' WHERE pr.product_id IN ('.implode(',',$ids).')';
						$database->setQuery($query);
						$rows = $database->loadObjectList();
						$types['related']->type = 'text';
						foreach($elements as $element){
							foreach($element as $key=>$related){
								if($key == 'related'){
									foreach($related as $product){
										$product->related = '';
										foreach($rows as $row){
											if($element->product_id != $row->product_id){continue;}
											$product->related = $row->product_code;
										}
									}
								}
							}
						}
						break;
					case 'category':
						unset($action['category']);
						$database = JFactory::getDBO();
						$ids = array();

						foreach($elements as $element){
							foreach($element as $key=>$data){
								if($key == 'category'){
									foreach($data as $category){
										if(isset($category->category_id)){
											$ids[] = (int)$category->category_id;
										}
									}
								}
							}
						}
						if(!empty($ids)){
							$query = 'SELECT DISTINCT category_name, category_id';
							$query .= ' FROM '.hikashop_table('category');
							$query .= ' WHERE category_id IN ('.implode(',',$ids).')';
							$database->setQuery($query);
							$rows = $database->loadObjectList();
							foreach($elements as $element){
								foreach($element as $key=>$data){
									if($key == 'category'){
										foreach($data as $category){
											if(isset($category->category_id)){
												$array = array();
												foreach($rows as $row){
													if($row->category_id == $category->category_id){
														$array[] = $row->category_name;
													}
												}
												$category->categories = $this->separator($array,$data,$table);
												$types['categories'] = new stdClass();
												$types['categories']->type = 'text';
												$action['category']['categories'] = 'categories';
											}
										}
									}
								}
							}
						}
						break;
				}
				break;
			case 'user':
				switch($table){
					case 'address':
						foreach($elements as $element){
							if(!isset($element->address)){continue;}
							foreach($element->address as $k=>$address){
								if($address->address_default != 1){
									unset($element->address[$k]);
								}
							}
						}
						break;
				}
				break;
			case 'category':
				unset($action['category']);
				$database = JFactory::getDBO();
				$ids = array();

				foreach($elements as $category){
					if(isset($category->category_id)){
						$ids[] = (int)$category->category_id;
					}
					if(isset($category->category_parent_id)){
						$ids[] = (int)$category->category_parent_id->id;
					}
				}
				if(!empty($ids)){
					$query = 'SELECT DISTINCT category_name, category_id';
					$query .= ' FROM '.hikashop_table('category');
					$query .= ' WHERE category_id IN ('.implode(',',$ids).')';
					$database->setQuery($query);
					$rows = $database->loadObjectList();
					foreach($elements as $category){
						if(isset($category->category_parent_id->id)){
							$array = array();
							foreach($rows as $row){
								if($row->category_id == $category->category_parent_id->id){
									$array[] = $row->category_name;
								}
							}
							$category->parent_category = $this->separator($array,$data,$table);
							$types['parent_category']->type = 'text';
							$action['category']['parent_category'] = 'parent_category';
						}
						if(isset($category->category_id)){
							$array = array();
							foreach($rows as $row){
								if($row->category_id == $category->category_id){
									$array[] = $row->category_name;
								}
							}
							$category->categories = $this->separator($array,$data,$table);
							$types['categories']->type = 'text';
							$action['category']['categories'] = 'categories';
						}
					}
				}
				break;
			case 'order':
				switch($table){
					case 'address':
						if(isset($action['address'])){
							foreach($elements as $element){
								$element->shipping_address = array();
								$element->billing_address = array();
								if(!isset($element->address)){continue;}
								foreach($element->address as $address){
									if($address->address_id === $element->order_shipping_address_id && $address->address_id === $element->order_billing_address_id){
										$object = new stdClass();
										foreach($address as $column=>$value){
											if(isset($action['address'][$column])){continue;}
											$shipping_column = 'shipping_'.$column;
											$billing_column = 'billing_'.$column;
											$action['shipping_address']->$shipping_column = $shipping_column;
											$action['billing_address']->$billing_column = $billing_column;
											$object->$shipping_column=$value;
											$object->$billing_column=$value;
											$types[$billing_column]->type = $types[$column]->type;
											$types[$shipping_column]->type = $types[$column]->type;
										}
										$element->shipping_address[] = $object;
										$element->billing_address[] = $object;
									}else if($address->address_id === $element->order_shipping_address_id){
										$object = new stdClass();
										foreach($address as $column=>$value){
											if(isset($action['address'][$column])){continue;}
											$shipping_column = 'shipping_'.$column;
											$action['shipping_address']->$shipping_column = $shipping_column;
											$object->$shipping_column=$value;
											$types[$shipping_column]->type = $types[$column]->type;
										}
										$element->shipping_address[] = $object;
									}else if($address->address_id === $element->order_billing_address_id){
										$object = new stdClass();
										foreach($address as $column=>$value){
											if(!isset($action['address'][$column])){continue;}
											$billing_column = 'billing_'.$column;
											$action['billing_address']->$billing_column = $billing_column;
											$object->$billing_column=$value;
											$types[$billing_column]->type = $types[$column]->type;
										}
										$element->billing_address[] = $object;
									}
								}
							}
							unset($action['address']);
						}
						break;
					case 'order_product':
						if(isset($action['order_product'])){
							foreach($elements as $element){
								$cpt = 1;
								if(!isset($element->order_product)){continue;}
								if(!isset($element->order_full_tax)){
									$element->order_full_tax = new stdClass();
									$element->order_full_tax->value = 0;
								//	$action['order']['order_full_tax'] = 'order_full_tax';
									$types['order_full_tax'] = new stdClass();
									$types['order_full_tax']->type = 'price';
								}

								if(!isset($element->order_shipping_tax->value)){
									$tmpValue = (int)$element->order_shipping_tax;
									$element->order_shipping_tax = new stdClass();
									$element->order_shipping_tax->value = $tmpValue;
								}
								if(!isset($element->order_discount_tax->value)){
									$tmpValue = (int)$element->order_discount_tax;
									$element->order_discount_tax = new stdClass();
									$element->order_discount_tax->value = $tmpValue;
								}
								$element->order_full_tax->value += (int)$element->order_shipping_tax->value - (int)$element->order_discount_tax->value;
								$element->order_full_tax->currency = $element->order_currency_id;
								foreach($element->order_product as $product){
									if(isset($product->order_product_quantity) && isset($product->order_product_tax)){
										$element->order_full_tax->value+=round($product->order_product_quantity*$product->order_product_tax,2);
									}
									$tablename = 'product'.$cpt;
									$object = new stdClass();
									foreach($product as $column=>$value){
										if(!isset($action['order_product'][$column])){continue;}
										$product_column = 'item'.$cpt.'_'.$column;
										if(!isset($action[$tablename]))
											$action[$tablename] = new stdClass();
										$action[$tablename]->$product_column = $product_column;
										$object->$product_column = $value;
										$types[$product_column] = new stdClass();

										if(isset($types[$column]->type)){
											$types[$product_column]->type = $types[$column]->type;
										}else{
											$types[$product_column]->type = '';
										}
									}
									$element->$tablename = array($object);
									$cpt++;
								}
							}
							unset($action['order_product']);
						}
						break;
					case 'joomla_users':
						if(isset($action['joomla_users'])){
							foreach($elements as $element){
								foreach($element->joomla_users as $joomla_users){
									foreach($joomla_users as $column=>$value){
										$types[$column] = new stdClass();
										if(!isset($types[$column]->type)){
											$types[$column]->type = '';
										}
									}
								}
							}
						}
						break;
				}
				break;
		}
	}

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 0
10 years 4 months ago #164971

Hi thanks for the prompt reply much appreciated, but I have tried the fix that you suggested and i still get the same results I have attached the output of my file so you can see what I mean. At the top of the table you can see that the bottle size and category field is empty but near the bottom of the table the bottle size and category is present, i need the bottle size to be present on all variations of products and not just the main product. I hope this makes sense.


File Attachment:

File Name: hd390975.csv
File Size:158 KB



Thanks

Attachments:
Last edit: 10 years 4 months ago by cefnllys.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 4 months ago #165006

Hi,

On my end all the variants have their characteristic value in the csv file.
So I am not able to reproduce your issue on my end.

Are you sure that your variants are valid ? Could you give us screenshots of the variant listing of one product ?
And on another screenshot of the edition page of one of these variants ?

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 0
10 years 3 months ago #165105

Is this what you mean? As far as I can tell everything is correct



Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 3 months ago #165108

Hi,

Do you have a recent version of HikaShop ?

As I am not able to reproduce the issue on my end, could you give me a backend and FTP access in order to debug it directly on your website ?
You can send informations via pm with a link to this topic.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 0
10 years 3 months ago #166469

Any News/Update on this?

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 0
10 years 3 months ago #166682

I could really do with knowing whether your looking into this or if I'm going to have to start trying to work it out myself. My deadline is looming ever closer.

Thanks Cefnllys

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 3 months ago #166708

Hi,

Do you have a recent version of HikaShop ?

As I am not able to reproduce the issue on my end, could you give me a backend and FTP access in order to debug it directly on your website ?
You can send informations via pm with a link to this topic.

We still don't have the required information (ftp access, information about your version, etc) so it will be difficult to help you if we don't have answers.

So no, we can't have any news if we are still waiting for answers.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 0
10 years 3 months ago #166769

Jerome wrote: Hi,

Do you have a recent version of HikaShop ?

As I am not able to reproduce the issue on my end, could you give me a backend and FTP access in order to debug it directly on your website ?
You can send informations via pm with a link to this topic.

We still don't have the required information (ftp access, information about your version, etc) so it will be difficult to help you if we don't have answers.

So no, we can't have any news if we are still waiting for answers.

Regards,


well I did PM Xavier with the details a few days ago should I instead PM you with the details instead?

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 3 months ago #166781

Hi,

Xavier filled some elements in your ticket, with a backend access by without the FTP access.
He is currently in holidays so yes, it will be better to send me a PM to complete the credential information in order to be able to make some tests.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 0
10 years 3 months ago #166978

Hi Jerome, I have PM'd you the details. Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 3 months ago #167060

Hi,

The user account access you provided didn't allow us to access your backend.
Could you double check it ?
We need to look at how you configured your mass action. I'm guessing that maybe some fields are missing from the export and that the mass action system rely on them to be there to get the variants data for the CSV generation or something like that.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 0
10 years 3 months ago #167111

Hi nicolas I have PM'd you again with the new details

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 3 months ago #167352

Thanks. The new access finally allowed us to work on the issue and find a solution.
It was actually caused by the space in the name of your characteristic which wasn't taking into account properly by the mass actions export system.
We've modified the way the export is done in order to handle that properly.
It's already fixed on your website and we successfully tested the patch on your website.

For anyone with a similar problem, the patch will of course be included in the next version of HikaShop, and here is the administrator/components/com_hikashop/classes/massaction.php file which you can replace to fix the problem if you don't want to wait for the next release:

File Attachment:

File Name: massaction...8-14.zip
File Size:16 KB

Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.117 seconds
Powered by Kunena Forum