When copying linked products from one category to another:
the From Category is checked for the existence of products to copy, ok
the To Category is checked for the existence of products too: not ok. It should check for the existence of the To Category and that there are no subcategories, it doesn't matter if there are no products in there.
Suggestion
from
PHP Code:
$check_category_to = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $copy_to_linked . "' limit 1");
// check if from is valid category
if ($check_category_from->RecordCount() < 1) {
$zv_invalid_copy_linked = 'true';
$zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $copy_from_linked . ' ';
} else {
$zv_complete_message_linked .= SUCCESS_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $copy_from_linked . ' ';
}
// check if to is valid category
if ($check_category_to->RecordCount() < 1) {
if (zen_childs_in_category_count($copy_to_linked) > 0) {
$zv_invalid_copy_linked = 'true';
$zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $copy_to_linked . ' ';
}
$zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED_MISSING . $copy_to_linked . ' ';
} else {
$zv_complete_message_linked .= SUCCESS_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $copy_to_linked . ' ';
}
to
PHP Code:
$check_category_to = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_id='" . $copy_to_linked . "' limit 1");
// check if from is valid category
if ($check_category_from->RecordCount() < 1) {
$zv_invalid_copy_linked = 'true';
$zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $copy_from_linked . ' ';
} else {
$zv_complete_message_linked .= SUCCESS_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $copy_from_linked . ' ';
}
// check if to is valid category
if ($check_category_to->RecordCount() > 0) {
if (zen_childs_in_category_count($copy_to_linked) > 0) {
$zv_invalid_copy_linked = 'true';
$zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $copy_to_linked . ' ';
}
$zv_complete_message_linked .= SUCCESS_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $copy_to_linked . ' ';
} else {
$zv_invalid_copy_linked = 'true';
$zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED_MISSING . $copy_to_linked . ' ';
}
and add more information in the constants:
to
PHP Code:
define('WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED', 'Invalid Category (no products) to link Products From: ');
define('WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED', 'Invalid Category (has subcategories) to link Products To: ');
define('WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED_MISSING', 'WARNING: Copy not allowed to Invalid (missing) Category to Link: ');