Jump to content

Recommended Posts

Заранее извиняюсь за банальные вопросы, помогите строчкой в файле импорта. Сам я далек от написания кода.

Моя проблема связана с тем, что при импорте, если я перенес товар в другую категорию, в карточке товара создается еще одна категория, т.е. у товара становится 2 категории.

Как сделать чтобы если в карточке уже есть категория, он не создавал дополнительную, а обновлял ее ?

Я так понимаю ковырять нужно этот кусок в файле import.php ?

if(!empty($categories_ids))
			foreach($categories_ids as $c_id)
				$this->categories->add_product_category($product_id, $c_id);

 

Link to post
Share on other sites

Вроде написал кусок кода... Вроде даже работает... Насколько он правильный, сказать не могу...
 

if(!empty($categories_ids))
			foreach($categories_ids as $c_id)
			if(empty($category_id))				
				$this->categories->add_product_category($product_id, $c_id);
			elseif(!empty($category_id))
			$this->db->query('DELETE FROM __products_categories WHERE product_id = ?', $product_id);
			$this->categories->add_product_category($product_id, $c_id);

 

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...