Jump to content

Последовательность добавления варинтов при импорте


Recommended Posts

Возможно эта тема поднималась, не нашел соответствующей темы. пишу пока увидел небольшой недочет. При импорте варианты не имеют последовательности.

 

стандартный код в файле import.php



// Иначе - добавляем
elseif(empty($variant_id))
{
   if(empty($product_id))
   $product_id = $this->products->add_product($product);
   $variant['product_id'] = $product_id;
   $variant_id = $this->variants->add_variant($variant);
   $imported_item->status = 'added';
}

 

меняем на:

 



			// Иначе - добавляем
			elseif(empty($variant_id))
			{
				if(empty($product_id))
					$product_id = $this->products->add_product($product);

                $this->db->query('SELECT max(v.position) as pos FROM __variants v WHERE v.product_id=? LIMIT 1', $product_id);
                $pos =  $this->db->result('pos');

				$variant['position'] = $pos+1;
				$variant['product_id'] = $product_id;
				$variant_id = $this->variants->add_variant($variant);
				$imported_item->status = 'added';
			}
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...