PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]
Botoscope is currently in early access

Support Forum

You need to log-in to create request (topic) to the support

ascending SKUs for bulk edit

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hello,

I am using BEAR Bulk Editor Professional in my WooCommerce shop (Electro theme, many bundle products with ATUM inventory management).

I would like to replace SKUs for multiple selected products and automatically generate ascending SKUs, for example from 10300 to 10330.

I tried entering 10300+ in the SKU field, but BEAR just saves it as text and does not generate sequential numbers.

Could you please tell me:

  1. What is the correct syntax to generate sequential SKUs in BEAR?

  2. Does this work for simple products and variations?

  3. Is there a recommended method when using ATUM or bundle products to avoid SKU conflicts?

Example:
Product 1 → 10300
Product 2 → 10301
Product 3 → 10302

Thank you very much for your help!

Hello

There is no such feature in the current version, but is is good idea, we modificated code and now result is: https://share.pluginus.net/image/i20260226173854.png

You can apply this code now:

  • go to file wp-content\plugins\woo-bulk-editor\ext\bulk\bulk.php
  • find function private function _process_text_data and completely replace it to the next code:
    private function _process_text_data($woobe_bulk, $field_key, $product_id) {
            $val = $this->products->get_post_field($product_id, $field_key);
    
            // Auto-increment SKU: supports patterns like"10300+","10300+5","PREFIX-10300+","PREFIX-10300+5"
            // Syntax: {prefix}{number}+{step} where prefix and step are optional, step defaults to 1
            if ($field_key === 'sku' && isset($woobe_bulk[$field_key]['value']) && preg_match('/^(.*?)(\d+)\+(\d*)$/', $woobe_bulk[$field_key]['value'], $matches)) {
                static $woobe_sku_counter = null; // current counter value
                static $woobe_sku_pattern = null; // last seen pattern, used to detect new bulk run
                static $woobe_sku_step = 1;    // increment step
    
                $sku_prefix = $matches[1];           // e.g."ABC-" or"" if none
                $sku_start = intval($matches[2]);   // e.g. 10300
                $sku_step = !empty($matches[3]) ? intval($matches[3]) : 1; // e.g. 5, default 1
    
                $pattern_key = $woobe_bulk[$field_key]['value'];
    
                // Reset counter when a new bulk operation starts (new pattern detected)
                if ($woobe_sku_pattern !== $pattern_key) {
                    $woobe_sku_counter = $sku_start;
                    $woobe_sku_pattern = $pattern_key;
                    $woobe_sku_step = $sku_step;
                }
    
                // Override the value with the generated sequential SKU
                $woobe_bulk[$field_key]['value'] = $sku_prefix . $woobe_sku_counter;
    
                // Increment counter for the next product
                $woobe_sku_counter += $woobe_sku_step;
            }
            
            //+++
    
            $woobe_bulk[$field_key]['value'] = $this->products->string_macros($woobe_bulk[$field_key]['value'], $field_key, $product_id);
            switch ($woobe_bulk[$field_key]['behavior']) {
                case 'append':
                    $val = $this->products->string_replacer($val . $woobe_bulk[$field_key]['value'], $product_id);
                    break;
                case 'prepend':
                    $val = $this->products->string_replacer($woobe_bulk[$field_key]['value'] . $val, $product_id);
                    break;
                case 'new':
                    $val = $this->products->string_replacer($woobe_bulk[$field_key]['value'], $product_id);
                    break;
                case 'replace':
                    $replace_to = $this->products->string_replacer($woobe_bulk[$field_key]['replace_to'], $product_id);
                    $replace_from = $this->products->string_replacer($woobe_bulk[$field_key]['value'], $product_id);
    
                    //fix  for  apostrophe
                    $replace_from = str_replace("\'","'", $replace_from);
    
                    if ($woobe_bulk[$field_key]['case'] == 'ignore') {
                        $val = str_ireplace($replace_from, $replace_to, $val);
                    } else {
                        $val = str_replace($replace_from, $replace_to, $val);
                        /*
                         * https://stackoverflow.com/questions/19317493/php-preg-replace-case-insensitive-match-with-case-sensitive-replacement
                          $val = preg_replace_callback('/\b' . $replace_from . '\b/i', function($matches) use ($replace_to) {
                          $i = 0;
                          return join('', array_map(function($char) use ($matches, &$i) {
                          return ctype_lower($matches[0][$i++]) ? strtolower($char) : strtoupper($char);
                          }, str_split($replace_to)));
                          }, $val);
                         *
                         */
                    }
    
                    break;
            }
    
            //***
            $empty_exceptions = array('tax_class'); //setting empty values is possible with this fields
    
            $can = true; //!empty($val);
    
            if (in_array($field_key, $empty_exceptions)) {
                $can = true;
            }
    
            if ($can) {
    
                $val = $this->products->update_page_field($product_id, $field_key, $val);
            }
        }

     

Try it :)