Error on Import

  • Posts: 41
  • Thank you received: 0
10 years 5 months ago #191896

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.6.3
-- Browser(s) name and version -- : Chrome
-- Error-message(debug-mod must be tuned on) -- : 1136 Column count doesn't match value count at row 1 SQL=INSERT IGNORE INTO jbar3_hikashop_product_related (`product_related_id`,`product_related_type`,`product_id`) VALUES ()

Not really sure why this error would happen. Here are the steps. (furnitureandthings.com - upgrade to joomla 3)
1. I exported my products from hikashop2.3.5 FOR JOOMLA 2.5.28 (from live site)
2. Created fresh JOOMLA 3.3.6 site on local machine. Loaded hikashop version 2.3.5 (so it matches)
3. Imported product list (from step 1)

And this error shows up. Pleae explain the issue. I would think it should be seamless.

awesomescreenshot.com/0a34gzhp2b

Thanks!

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

  • Posts: 26264
  • Thank you received: 4043
  • MODERATOR
10 years 5 months ago #192112

Hi,

I check the code of the import but I find something which could explain your issue.
In the file "administrator/components/com_hikashop/helpers/import.php", you will find the function "_insertRelated".
In this function, please replace the two references of

if( $totalValid%$this->perBatch == 0){
By
if( $totalValid && $totalValid%$this->perBatch == 0){
And it should fix your issue.
Near the end of the function, you can also replace
if(!empty($values)){
By
if(count($values) > 0){

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: 41
  • Thank you received: 0
10 years 5 months ago #192835

Unfortunately that did not work. I still get this error:

1136 Column count doesn't match value count at row 1 SQL=INSERT IGNORE INTO jbar3_hikashop_product_related (`product_related_id`,`product_related_type`,`product_id`) VALUES ()

I reverted back to the original. Realy need this to work as these products have many related products and I would think we should be able to export and import seamlessly between hikashop.

Thanks!

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

  • Posts: 13201
  • Thank you received: 2322
10 years 5 months ago #192901

Hi,

Please replace the whole content of the function by:

	function _insertRelated(&$products,$type='related'){
		$values = array();
		$totalValid=0;
		$insert = 'INSERT IGNORE INTO '.hikashop_table('product_related').' (`product_related_id`,`product_related_type`,`product_id`) VALUES (';
		$ids=array();

		foreach($products as $product){
			if(!isset($product->$type) && empty($product->hikashop_update)){
				//copy files from template if any
				if(@$product->product_type!='variant' && !empty($this->template->$type)){
					foreach($this->template->$type as $id){
						$value = array((int)$id,$this->db->Quote($type),$product->product_id);
						$values[] = implode(',',$value);
						$totalValid++;
						if( $totalValid && $totalValid%$this->perBatch == 0){
							$this->db->setQuery($insert.implode('),(',$values).')');
							$this->db->query();
							$totalValid=0;
							$values=array();
						}
					}
				}
			}elseif(isset($product->$type)&&is_array($product->$type)){
				$ids[] = (int)$product->product_id;
				foreach($product->$type as $k => $id){
					if(!empty($id)){
						$id = $this->_getRelated($id);
						$product->{$type}[$k] = $id;
						$value = array((int)$id,$this->db->Quote($type),$product->product_id);
						$values[] = implode(',',$value);
						$totalValid++;
					}
					if( $totalValid && $totalValid%$this->perBatch == 0){
						if(!empty($ids)){
							$this->db->setQuery('DELETE FROM '.hikashop_table('product_related').' WHERE product_id IN ('.implode(',',$ids).') AND product_related_type='.$this->db->Quote($type));
							$this->db->query();
							$ids=array();
						}
						if(!empty($id)){
							$this->db->setQuery($insert.implode('),(',$values).')');
							$this->db->query();
						}
						$totalValid=0;
						$values=array();
					}
				}
			}
		}
		if(!empty($ids)){
			$this->db->setQuery('DELETE FROM '.hikashop_table('product_related').' WHERE product_id IN ('.implode(',',$ids).') AND product_related_type='.$this->db->Quote($type));
			$this->db->query();
		}
		if(count($values)){
			$this->db->setQuery($insert.implode('),(',$values).')');
			$this->db->query();
		}
	}

The following user(s) said Thank You: gteigland

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

Time to create page: 0.069 seconds
Powered by Kunena Forum