Jump to content

Edit History

knacky

knacky

It is better to use Prestashop functions to edit the category association.

$product = new Product((int)$id_product);
$getCategories = Product::getProductCategories((int)$id_product);
$categories = array();
$stockOffVar = $_POST["tipodesc"]; 
$keeping_current_pos = false;
$clean_positions = true;
if ($stockOffVar == 'Outlet50'){
	$categories[] = '3470';
	foreach ($getCategories as $category){
		$categories[] = $category['id_category'];
	}

	$product->updateCategories($categories, $keeping_current_pos);

} else {
	$product->deleteCategory('3470', $clean_positions);
}

 

knacky

knacky

It is better to use Prestashop functions to edit the category association.

$product = new Product((int)$id_product);
$getCategories = Product::getProductCategories((int)$id_product);
$categories = array();
$stockOffVar = $_POST["tipodesc"]; 
$keeping_current_pos = ;
$clean_positions = true;
if ($stockOffVar == 'Outlet50'){
	$categories[] = '3470';
	foreach ($getCategories as $category){
		$categories[] = $category['id_category'];
	}

	$product->updateCategories($categories, $keeping_current_pos);

} else {
	$product->deleteCategory('3470', $clean_positions);
}

 

knacky

knacky

It is better to use Prestashop functions to edit the category association.

$product = new Product((int)$id_product);
$getCategories = Product::getProductCategories((int)$id_product);
$categories = array();
$stockOffVar = $_POST["tipodesc"]; 
$keeping_current_pos = true;
$clean_positions = true;
if ($stockOffVar == 'Outlet50'){
	$categories[] = '3470';
	foreach ($getCategories as $category){
		$categories[] = $category['id_category'];
	}

	$product->updateCategories($categories, $keeping_current_pos);

} else {
	$product->deleteCategory('3470', $clean_positions);
}

 

knacky

knacky

It is better to use Prestashop functions to edit the category association.

 

×
×
  • Create New...