Add Extra Secondary Categories To Selected Products

How can we add an extra secondary category through bulk edit for multiple products ?

Currently it replaces the existing category instead of adding another one , any option to do that apart from export and then manually add in xls and then import it again.

What do you mean then you say that the categories are overrided in bulk editing? I have just tested it on demo, and secondary categories were added to product. Main category remained the same

What do you mean then you say that the categories are overrided in bulk editing? I have just tested it on demo, and secondary categories were added to product. Main category remained the same

What field do you edit and add from bulk edit for the secondary category addition ?

We tried it by using the Categories field only and it replaces the same in the product.

We are on version 4.2.4 Multi Vendor

http://prntscr.com/bokjkj

just tested in 424 with the Categories parameter.

Before:

http://prntscr.com/bol06d

After:

http://prntscr.com/bol0dl

just tested in 424 with the Categories parameter.

Before:

http://prntscr.com/bol06d

After:

http://prntscr.com/bol0dl

I think OP means when applying values to all products, not 1 by 1. I had same issue

Yes thats exactly the issue. We can add the categ 1 by 1 but what we want to do is add 1 categ as a secondary categ to selected products in 1 go.

Yes thats exactly the issue. We can add the categ 1 by 1 but what we want to do is add 1 categ as a secondary categ to selected products in 1 go.


Ah, sorry. I misunderstood you.

app/controllers/backend/products.php

Try to replace:

            foreach (Tygh::$app['session']['product_ids'] as $_o => $p_id) {
                // Update product
                fn_update_product($product_data, $p_id, DESCR_SL);
            }

with

            $common_categories = !empty($product_data['category_ids']) ? $product_data['category_ids'] : array();
            foreach (Tygh::$app['session']['product_ids'] as $_o => $p_id) {
                // Update product
                $product_data['category_ids'] = $common_categories;
            $data = db_get_array("SELECT * FROM ?:products_categories WHERE product_id = ?i ORDER BY link_type ASC", $p_id);

            foreach ($data as $v) {
                array_unshift($product_data['category_ids'], $v['category_id'];
            }

            fn_update_product($product_data, $p_id, DESCR_SL); 
       }

(!) Not tested

Thanks for the code will try and let you know.

What we had thought the default functionality was that you add an extra category using the option "Apply values to all the selected products"

And then dont select the category you added to make it a secondary category as normal behavior in the product update page as well.

To make the Category as main you have to select it.

So here also we tried both the option of choosing the category added as well as not choosing it after adding and applying it to all products but it turned out that eventually it replaces all the categories of the products with this newly added category.