Jump to content

[RESOLVED] Cloned Product Keeps Stock Level??


Dirty Butter

Recommended Posts

Two parts: adding a setting in Store Settings, Extra, and adding test for that setting.

In the admin skin template settings.index.php:

Find:

<div><label for="product_clone_images">{$LANG.settings.product_clone_images}</label><span><input name="config[product_clone_images]" id="product_clone_images" type="hidden" class="toggle" value="{$CONFIG.product_clone_images}"></span></div>
<div><label for="product_clone_options">{$LANG.settings.product_clone_options}</label><span><input name="config[product_clone_options]" id="product_clone_options" type="hidden" class="toggle" value="{$CONFIG.product_clone_options}"></span></div>
<div><label for="product_clone_options_matrix">{$LANG.settings.product_clone_options_matrix}</label><span><input name="config[product_clone_options_matrix]" id="product_clone_options_matrix" type="hidden" class="toggle" value="{$CONFIG.product_clone_options_matrix}"></span></div>
<div><label for="product_clone_acats">{$LANG.settings.product_clone_acats}</label><span><input name="config[product_clone_acats]" id="product_clone_acats" type="hidden" class="toggle" value="{$CONFIG.product_clone_acats}"></span></div>

Add after:

<div><label for="product_clone_main_stock">Main stock level</label><span><input name="config[product_clone_main_stock]" id="product_clone_main_stock" type="hidden" class="toggle" value="{$CONFIG.product_clone_main_stock}"></span></div>

You can add a phrase to the language pack if you want.

Then, in /admin/sources/products.index.inc.php:

Find:

$record = $original_product_data[0];

// Add cloned product
$date_added = date('Y-m-d H:i:s', time());
$record['date_added'] = $date_added;
$record['updated'] = $date_added;

if ($GLOBALS['config']->get('config', 'product_clone_code') == 1)
  $record['product_code'] = generate_product_code($record['name']);

Add after:

if ($GLOBALS['config']->get('config', 'product_clone_main_stock') != 1)
  unset($record['stock_level']);

 

Edited by bsmither
Fixed added PHP statement
Link to comment
Share on other sites

It's not working for me, and I've tried it several times - with and then without my usual comments before and after changes.

		$record = $original_product_data[0];

		// Add cloned product
		$date_added = date('Y-m-d H:i:s', time());
		$record['date_added'] = $date_added;
		$record['updated'] = $date_added;

		if ($GLOBALS['config']->get('config', 'product_clone_code') == 1)
			$record['product_code'] = generate_product_code($record['name']);
 if ($GLOBALS['config']->get('config', 'product_clone_main_stock') != 1)
  unset($record['stock_level']; 
		unset($record['product_id'], $record['popularity']);

AND

         <div><label for="product_clone_images">{$LANG.settings.product_clone_images}</label><span><input name="config[product_clone_images]" id="product_clone_images" type="hidden" class="toggle" value="{$CONFIG.product_clone_images}"></span></div>
         <div><label for="product_clone_options">{$LANG.settings.product_clone_options}</label><span><input name="config[product_clone_options]" id="product_clone_options" type="hidden" class="toggle" value="{$CONFIG.product_clone_options}"></span></div>
         <div><label for="product_clone_options_matrix">{$LANG.settings.product_clone_options_matrix}</label><span><input name="config[product_clone_options_matrix]" id="product_clone_options_matrix" type="hidden" class="toggle" value="{$CONFIG.product_clone_options_matrix}"></span></div>
         <div><label for="product_clone_acats">{$LANG.settings.product_clone_acats}</label><span><input name="config[product_clone_acats]" id="product_clone_acats" type="hidden" class="toggle" value="{$CONFIG.product_clone_acats}"></span></div>
         <div><label for="product_clone_code">{$LANG.settings.product_clone_code}</label><span><select name="config[product_clone_code]" id="product_clone_code" class="textbox">
  <div><label for="product_clone_main_stock">Main stock level</label><span><input name="config[product_clone_main_stock]" id="product_clone_main_stock" type="hidden" class="toggle" value="{$CONFIG.product_clone_main_stock}"></span></div>         
 {foreach from=$OPT_PRODUCT_CLONE_CODE item=option}<option value="{$option.value}"{$option.selected}>{$option.title}</option>{/foreach}

 

I do NOT use the Option Matrix - would that make a difference?

Link to comment
Share on other sites

Double check the HTML:

1: <div><label for="product_clone_options_matrix">{$LANG.settings.product_clone_options_matrix}</label><span><input name="config[product_clone_options_matrix]" id="product_clone_options_matrix" type="hidden" class="toggle" value="{$CONFIG.product_clone_options_matrix}"></span></div>

2: <div><label for="product_clone_acats">{$LANG.settings.product_clone_acats}</label><span><input name="config[product_clone_acats]" id="product_clone_acats" type="hidden" class="toggle" value="{$CONFIG.product_clone_acats}"></span></div>

3: <div><label for="product_clone_code">{$LANG.settings.product_clone_code}</label><span><select name="config[product_clone_code]" id="product_clone_code" class="textbox">

4: <div><label for="product_clone_main_stock">Main stock level</label><span><input name="config[product_clone_main_stock]" id="product_clone_main_stock" type="hidden" class="toggle" value="{$CONFIG.product_clone_main_stock}"></span></div>         

Move line 4 between lines 2 and 3.

And how is it not working? Do you see or not see the choice in the admin screen?

Link to comment
Share on other sites

I agree that stock level is not an inherent characteristic of a cloned product.

I believe its translated description(s), image(s), options, options matrix, and categories are inherent characteristics of a cloned product. These are specific inherent characteristics that can be switched off for the cloning process.

Other non-inherent characteristics are: date added, date updated, product code, product id, and popularity. These are not copied in the cloning process.

So, yes, I believe main stock levels (and, perhaps, matrix stock levels, but keep the matrix) should not be copied in the cloning process.

Link to comment
Share on other sites

  • 2 weeks later...

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.

×
×
  • Create New...