Too many characteristics - stop creation?

  • Posts: 2
  • Thank you received: 1
11 years 3 months ago #119534

Hi

We have several characteristics each with several possible options. Of course when we add these to a product it creates thousands of rows in the database due to the 10x10x10x10 = 10000s

However, we do not need all these rows as products only need one or two of each possible characteristic (i.e. not all 10 possible options for each) so each product would only really need up to 60 rows.

Is it possible to suppress the auto-creation of all these rows in the database?

Thanks
Simon

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
11 years 3 months ago #119546

Hi Simon,

You'll probably find some information through this thread :

You have too much possibilities. For example, if you have 3 characteristics with 10 values each, that's 10*10*10=1000 possibilities. That's already too much.
You should indeed transform some characteristics into custom fields ( www.hikashop.com/en/support/documentatio...p-field-listing.html ) or options ( www.hikashop.com/en/support/documentatio...ct-form.html#options ) so that it becomes more manageable for your server.

Characteristics should only be used when you want to change some of the information on the products (the stock, the price, the image, etc). For choices which do not affect any of that custom fields of the table "item" are the way to go.

Please Log in or Create an account to join the conversation.

  • Posts: 2
  • Thank you received: 1
11 years 3 months ago #119551

Hi, I believe I managed to do this by commenting out the following pieces of code in product.php:

First this section:

if($variants>500){
								$this->database->setQuery($query.implode(',',$insert).';');
								$this->database->query();
								$this->database->setQuery('SELECT product_id,product_code FROM '.hikashop_table('product').' WHERE product_code IN ('.implode(',',$db_codes).')');
								$objs = $this->database->loadObjectList();
								foreach($objs as $obj){
									foreach($codes[$obj->product_code] as $k){
										$newVariants[]= '('.(int)$k.','.$obj->product_id.',0)';
									}
								}
								if(!empty($newVariants)){
									$this->database->setQuery('INSERT IGNORE INTO '.hikashop_table('variant').' (variant_characteristic_id,variant_product_id,ordering) VALUES '.implode(',',$newVariants));
									$this->database->query();
								}
								$codes=array();
								$variants=0;
								$insert=array();
								$db_codes=array();
								$newVariants =array();

and this section of code:
if(!empty($insert)){
						$this->database->setQuery($query.implode(',',$insert).';');
						$this->database->query();
						$this->database->setQuery('SELECT product_id,product_code FROM '.hikashop_table('product').' WHERE product_code IN ('.implode(',',$db_codes).')');
						$objs = $this->database->loadObjectList();
						foreach($objs as $obj){
							foreach($codes[$obj->product_code] as $k){
								$newVariants[]= '('.(int)$k.','.$obj->product_id.',0)';
							}
						}
						if(!empty($newVariants)){
							$this->database->setQuery('INSERT IGNORE INTO '.hikashop_table('variant').' (variant_characteristic_id,variant_product_id,ordering) VALUES '.implode(',',$newVariants));
							$this->database->query();
						}
					}

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.065 seconds
Powered by Kunena Forum