Skip to content

Commit 4489547

Browse files
authored
Merge pull request #57 from woocommerce/try/14
Limit attribute terms to 5 on variable products
2 parents e278568 + 9deb033 commit 4489547

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

includes/Generator/Product.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ protected static function create_global_attribute( $raw_name ) {
149149
* Generate attributes for a product.
150150
*
151151
* @param integer $qty Number of attributes to generate.
152+
* @param integer $maximum_terms Maximum number of terms per attribute to generate.
152153
* @return array Array of attributes.
153154
*/
154-
protected static function generate_attributes( $qty = 1 ) {
155+
protected static function generate_attributes( $qty = 1, $maximum_terms = 10 ) {
155156
$used_names = array();
156157
$attributes = array();
157158

@@ -190,7 +191,7 @@ protected static function generate_attributes( $qty = 1 ) {
190191

191192
$used_names[] = $raw_name;
192193

193-
$num_values = self::$faker->numberBetween( 1, 10 );
194+
$num_values = self::$faker->numberBetween( 1, $maximum_terms );
194195
$values = array();
195196
$existing_values = self::$global_attributes[ $raw_name ];
196197

@@ -232,7 +233,7 @@ protected static function generate_variable_product() {
232233
$product = new \WC_Product_Variable();
233234

234235
$gallery = self::maybe_get_gallery_image_ids();
235-
$attributes = self::generate_attributes( self::$faker->numberBetween( 1, 3 ) );
236+
$attributes = self::generate_attributes( self::$faker->numberBetween( 1, 3 ), 5 );
236237

237238
$product->set_props( array(
238239
'name' => $name,

0 commit comments

Comments
 (0)