Skip to content

Instantly share code, notes, and snippets.

@amacgregor
Forked from ryaan-anthony/gist:6290973
Created November 14, 2013 16:20
Show Gist options
  • Select an option

  • Save amacgregor/7469622 to your computer and use it in GitHub Desktop.

Select an option

Save amacgregor/7469622 to your computer and use it in GitHub Desktop.

Revisions

  1. @ryaan-anthony ryaan-anthony revised this gist Aug 23, 2013. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,7 @@
    delimiter ;;
    drop procedure if exists big_catalog;;
    create procedure big_catalog()
    drop procedure if exists build_catalog;;
    create procedure build_catalog(IN categories INT, IN products INT)
    begin
    SET @category_limit = 10;
    SET @category_count = 1;
    SET @CATNAMEPREFIX = "Category ";
    SET @CATURLKEYPREFIX = "cat-";
    @@ -18,7 +17,7 @@ delimiter ;;
    SELECT @category_url_key_id := attribute_id from eav_attribute where attribute_code = 'url_key' and entity_type_id = @category_entity_type_id;
    SELECT @category_url_path_id := attribute_id from eav_attribute where attribute_code = 'url_path' and entity_type_id = @category_entity_type_id;

    WHILE @category_count < @category_limit DO
    WHILE @category_count < categories DO
    SELECT @category_entity_id := AUTO_INCREMENT from information_schema.tables where table_name = 'catalog_category_entity';
    INSERT INTO catalog_category_entity (entity_type_id,attribute_set_id,parent_id,created_at,updated_at,path,position,level,children_count) VALUES (@category_entity_type_id,@category_attribute_set_id,@ROOTCATEGORY,NOW(),NOW(),concat("1/2/", @category_entity_id),1,2,0);
    INSERT INTO catalog_category_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@include_in_menu,@category_entity_id,@INCLUDEINMENU);
    @@ -29,7 +28,6 @@ delimiter ;;
    SET @category_count = @category_count + 1;
    END WHILE;

    SET @product_limit = 30;
    SET @product_count = 1;
    SET @NAMEPREFIX = "Test Product ";
    SET @URLKEYPREFIX = "key-";
    @@ -58,7 +56,7 @@ delimiter ;;
    SELECT @url_key_id := attribute_id from eav_attribute where attribute_code = 'url_key' and entity_type_id = @entity_type_id;
    SELECT @url_path_id := attribute_id from eav_attribute where attribute_code = 'url_path' and entity_type_id = @entity_type_id;

    WHILE @product_count < @product_limit DO
    WHILE @product_count < products DO
    INSERT INTO catalog_product_entity (entity_type_id,attribute_set_id,type_id,sku,created_at,updated_at) VALUES (@entity_type_id,@attribute_set_id,"simple",concat(@SKUPREFIX, @product_count),NOW(),NOW());
    SELECT @entity_id := entity_id from catalog_product_entity order by entity_id desc limit 1;
    INSERT INTO catalog_product_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@visibility_id,@entity_id,@VISIBILITY);
    @@ -77,6 +75,7 @@ delimiter ;;
    INSERT INTO catalog_category_product_index (category_id,product_id,position,is_parent,visibility) VALUES(@last_id,@entity_id,1,1,4);
    INSERT INTO cataloginventory_stock_item (product_id,stock_id,qty,is_in_stock) VALUES (@entity_id,1,@QTY,1);
    INSERT INTO cataloginventory_stock_status (product_id,website_id,stock_id,qty,stock_status) VALUES (@entity_id,@WEBSITE,1,@QTY,1);
    INSERT INTO catalog_product_website (product_id,website_id) VALUES (@entity_id,@WEBSITE);
    SET @product_count = @product_count + 1;
    END WHILE;
    end
  2. @ryaan-anthony ryaan-anthony revised this gist Aug 22, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -76,6 +76,7 @@ delimiter ;;
    SELECT @last_id := category_id from catalog_category_product order by product_id desc limit 1;
    INSERT INTO catalog_category_product_index (category_id,product_id,position,is_parent,visibility) VALUES(@last_id,@entity_id,1,1,4);
    INSERT INTO cataloginventory_stock_item (product_id,stock_id,qty,is_in_stock) VALUES (@entity_id,1,@QTY,1);
    INSERT INTO cataloginventory_stock_status (product_id,website_id,stock_id,qty,stock_status) VALUES (@entity_id,@WEBSITE,1,@QTY,1);
    SET @product_count = @product_count + 1;
    END WHILE;
    end
  3. @ryaan-anthony ryaan-anthony revised this gist Aug 22, 2013. 1 changed file with 16 additions and 57 deletions.
    73 changes: 16 additions & 57 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -19,44 +19,19 @@ delimiter ;;
    SELECT @category_url_path_id := attribute_id from eav_attribute where attribute_code = 'url_path' and entity_type_id = @category_entity_type_id;

    WHILE @category_count < @category_limit DO

    SELECT @category_entity_id := AUTO_INCREMENT from information_schema.tables where table_name = 'catalog_category_entity';

    INSERT INTO catalog_category_entity (
    entity_type_id,
    attribute_set_id,
    parent_id,
    created_at,
    updated_at,
    path,
    position,
    level,
    children_count
    ) VALUES (
    @category_entity_type_id,
    @category_attribute_set_id,
    @ROOTCATEGORY,
    NOW(),
    NOW(),
    concat("1/2/", @category_entity_id),
    1,
    2,
    0
    );

    INSERT INTO catalog_category_entity (entity_type_id,attribute_set_id,parent_id,created_at,updated_at,path,position,level,children_count) VALUES (@category_entity_type_id,@category_attribute_set_id,@ROOTCATEGORY,NOW(),NOW(),concat("1/2/", @category_entity_id),1,2,0);
    INSERT INTO catalog_category_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@include_in_menu,@category_entity_id,@INCLUDEINMENU);
    INSERT INTO catalog_category_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@is_active,@category_entity_id,@ISACTIVE);
    INSERT INTO catalog_category_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@category_url_key_id,@category_entity_id,concat(@CATURLKEYPREFIX, @category_count));
    INSERT INTO catalog_category_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@category_url_path_id,@category_entity_id,concat(@CATURLPATHPREFIX, @category_count));
    INSERT INTO catalog_category_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@category_name_id,@category_entity_id,concat(@CATNAMEPREFIX, @category_count));

    SET @category_count = @category_count + 1;
    END WHILE;


    SET @product_limit = 30;
    SET @product_count = 1;
    SET @NAMEPREFIX = "Test Product #";
    SET @NAMEPREFIX = "Test Product ";
    SET @URLKEYPREFIX = "key-";
    SET @URLPATHPREFIX = "path-";
    SET @SKUPREFIX = "sku-";
    @@ -65,58 +40,42 @@ delimiter ;;
    SET @TAXCLASS = 2;
    SET @MAXPRICE = 100;
    SET @MAXWEIGHT = 20;
    SET @WEBSITE = 1;
    SET @STOREID = 1;
    SET @QTY = 999;
    SET @DESCRIPTION = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
    SET @SHORTDESCRIPTION = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";

    SELECT @entity_type_id := entity_type_id from eav_entity_type where entity_type_code = 'catalog_product';
    SELECT @attribute_set_id := attribute_set_id from eav_attribute_set where attribute_set_name = 'Default' and entity_type_id = @entity_type_id;

    SELECT @attribute_set_id := attribute_set_id from eav_attribute_set where attribute_set_name = 'Default' and entity_type_id = @entity_type_id;
    SELECT @visibility_id := attribute_id from eav_attribute where attribute_code = 'visibility' and entity_type_id = @entity_type_id;
    SELECT @status_id := attribute_id from eav_attribute where attribute_code = 'status' and entity_type_id = @entity_type_id;
    SELECT @taxclass_id := attribute_id from eav_attribute where attribute_code = 'tax_class_id' and entity_type_id = @entity_type_id;

    SELECT @taxclass_id := attribute_id from eav_attribute where attribute_code = 'tax_class_id' and entity_type_id = @entity_type_id;
    SELECT @description_id := attribute_id from eav_attribute where attribute_code = 'description' and entity_type_id = @entity_type_id;
    SELECT @short_description_id := attribute_id from eav_attribute where attribute_code = 'short_description' and entity_type_id = @entity_type_id;

    SELECT @short_description_id := attribute_id from eav_attribute where attribute_code = 'short_description' and entity_type_id = @entity_type_id;
    SELECT @price_id := attribute_id from eav_attribute where attribute_code = 'price' and entity_type_id = @entity_type_id;
    SELECT @weight_id := attribute_id from eav_attribute where attribute_code = 'weight' and entity_type_id = @entity_type_id;

    SELECT @name_id := attribute_id from eav_attribute where attribute_code = 'name' and entity_type_id = @entity_type_id;
    SELECT @url_key_id := attribute_id from eav_attribute where attribute_code = 'url_key' and entity_type_id = @entity_type_id;
    SELECT @url_path_id := attribute_id from eav_attribute where attribute_code = 'url_path' and entity_type_id = @entity_type_id;

    WHILE @product_count < @product_limit DO

    INSERT INTO catalog_product_entity (
    entity_type_id,
    attribute_set_id,
    type_id,
    sku,
    created_at,
    updated_at
    ) VALUES (
    @entity_type_id,
    @attribute_set_id,
    "simple",
    concat(@SKUPREFIX, @product_count),
    NOW(),
    NOW()
    );
    INSERT INTO catalog_product_entity (entity_type_id,attribute_set_id,type_id,sku,created_at,updated_at) VALUES (@entity_type_id,@attribute_set_id,"simple",concat(@SKUPREFIX, @product_count),NOW(),NOW());
    SELECT @entity_id := entity_id from catalog_product_entity order by entity_id desc limit 1;
    INSERT INTO catalog_product_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@visibility_id,@entity_id,@VISIBILITY);
    INSERT INTO catalog_product_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@status_id,@entity_id,@STATUS);
    INSERT INTO catalog_product_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@taxclass_id,@entity_id,@TAXCLASS);
    INSERT INTO catalog_product_entity_text (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@description_id,@entity_id,@DESCRIPTION);
    INSERT INTO catalog_product_entity_text (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@short_description_id,@entity_id,@SHORTDESCRIPTION);
    INSERT INTO catalog_product_entity_decimal (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@price_id,@entity_id,ROUND(RAND(2) * @MAXPRICE,2));
    INSERT INTO catalog_product_entity_decimal (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@weight_id,@entity_id,ROUND(RAND(2) * @MAXWEIGHT,2));
    INSERT INTO catalog_product_entity_decimal (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@price_id,@entity_id,ROUND(RAND() * @MAXPRICE,2));
    INSERT INTO catalog_product_entity_decimal (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@weight_id,@entity_id,ROUND(RAND() * @MAXWEIGHT,2));
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@url_key_id,@entity_id,concat(@URLKEYPREFIX, @product_count));
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,store_id,entity_id,value) VALUES(@entity_type_id,@url_path_id,@STOREID,@entity_id,concat(@URLPATHPREFIX, @product_count));
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@url_path_id,@entity_id,concat(@URLPATHPREFIX, @product_count));
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@name_id,@entity_id,concat(@NAMEPREFIX, @product_count));
    SELECT @category_entity_id := entity_id FROM catalog_category_entity WHERE parent_id = @ROOTCATEGORY ORDER BY RAND() LIMIT 1;
    INSERT INTO catalog_category_product (category_id,product_id,position) VALUES(@category_entity_id,@entity_id,1);
    INSERT INTO catalog_category_product_index (category_id,product_id,position,is_parent,visibility) VALUES(@category_entity_id,@entity_id,1,1,4);

    INSERT INTO catalog_category_product (category_id,product_id,position) VALUES((SELECT entity_id FROM catalog_category_entity WHERE parent_id = @ROOTCATEGORY ORDER BY RAND() LIMIT 1),@entity_id,1);
    SELECT @last_id := category_id from catalog_category_product order by product_id desc limit 1;
    INSERT INTO catalog_category_product_index (category_id,product_id,position,is_parent,visibility) VALUES(@last_id,@entity_id,1,1,4);
    INSERT INTO cataloginventory_stock_item (product_id,stock_id,qty,is_in_stock) VALUES (@entity_id,1,@QTY,1);
    SET @product_count = @product_count + 1;
    END WHILE;
    end
  4. @ryaan-anthony ryaan-anthony revised this gist Aug 21, 2013. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ delimiter ;;
    drop procedure if exists big_catalog;;
    create procedure big_catalog()
    begin
    SET @category_limit = 3;
    SET @category_limit = 10;
    SET @category_count = 1;
    SET @CATNAMEPREFIX = "Category ";
    SET @CATURLKEYPREFIX = "cat-";
    @@ -20,7 +20,7 @@ delimiter ;;

    WHILE @category_count < @category_limit DO

    SELECT @NEWID := AUTO_INCREMENT from information_schema.tables where table_name = 'catalog_category_entity';
    SELECT @category_entity_id := AUTO_INCREMENT from information_schema.tables where table_name = 'catalog_category_entity';

    INSERT INTO catalog_category_entity (
    entity_type_id,
    @@ -38,13 +38,12 @@ delimiter ;;
    @ROOTCATEGORY,
    NOW(),
    NOW(),
    concat("1/2/", @NEWID),
    concat("1/2/", @category_entity_id),
    1,
    2,
    0
    );

    SELECT @category_entity_id := entity_id from catalog_category_entity order by entity_id desc limit 1;
    INSERT INTO catalog_category_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@include_in_menu,@category_entity_id,@INCLUDEINMENU);
    INSERT INTO catalog_category_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@is_active,@category_entity_id,@ISACTIVE);
    INSERT INTO catalog_category_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@category_url_key_id,@category_entity_id,concat(@CATURLKEYPREFIX, @category_count));
    @@ -55,15 +54,15 @@ delimiter ;;
    END WHILE;


    SET @product_limit = 3;
    SET @product_limit = 30;
    SET @product_count = 1;
    SET @NAMEPREFIX = "Test Product #";
    SET @URLKEYPREFIX = "key-";
    SET @URLPATHPREFIX = "path-";
    SET @SKUPREFIX = "sku-";
    SET @VISIBILITY = 4;
    SET @STATUS = 1;
    SET @TAXCLASS = 1;
    SET @TAXCLASS = 2;
    SET @MAXPRICE = 100;
    SET @MAXWEIGHT = 20;
    SET @DESCRIPTION = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
    @@ -114,8 +113,9 @@ delimiter ;;
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@url_key_id,@entity_id,concat(@URLKEYPREFIX, @product_count));
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@url_path_id,@entity_id,concat(@URLPATHPREFIX, @product_count));
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@name_id,@entity_id,concat(@NAMEPREFIX, @product_count));
    SELECT @CATID := entity_id FROM catalog_category_entity WHERE parent_id = @ROOTCATEGORY ORDER BY RAND() LIMIT 1;
    INSERT INTO catalog_category_product (category_id,product_id,position) VALUES(@CATID,@entity_id,1);
    SELECT @category_entity_id := entity_id FROM catalog_category_entity WHERE parent_id = @ROOTCATEGORY ORDER BY RAND() LIMIT 1;
    INSERT INTO catalog_category_product (category_id,product_id,position) VALUES(@category_entity_id,@entity_id,1);
    INSERT INTO catalog_category_product_index (category_id,product_id,position,is_parent,visibility) VALUES(@category_entity_id,@entity_id,1,1,4);

    SET @product_count = @product_count + 1;
    END WHILE;
  5. @ryaan-anthony ryaan-anthony created this gist Aug 21, 2013.
    123 changes: 123 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,123 @@
    delimiter ;;
    drop procedure if exists big_catalog;;
    create procedure big_catalog()
    begin
    SET @category_limit = 3;
    SET @category_count = 1;
    SET @CATNAMEPREFIX = "Category ";
    SET @CATURLKEYPREFIX = "cat-";
    SET @CATURLPATHPREFIX = "catpath-";
    SET @ROOTCATEGORY = 2;
    SET @INCLUDEINMENU = 1;
    SET @ISACTIVE = 1;
    SELECT @category_entity_type_id := entity_type_id from eav_entity_type where entity_type_code = 'catalog_category';
    SELECT @category_attribute_set_id := attribute_set_id from eav_attribute_set where attribute_set_name = 'Default' and entity_type_id = @category_entity_type_id;
    SELECT @include_in_menu := attribute_id from eav_attribute where attribute_code = 'include_in_menu' and entity_type_id = @category_entity_type_id;
    SELECT @is_active := attribute_id from eav_attribute where attribute_code = 'is_active' and entity_type_id = @category_entity_type_id;
    SELECT @category_name_id := attribute_id from eav_attribute where attribute_code = 'name' and entity_type_id = @category_entity_type_id;
    SELECT @category_url_key_id := attribute_id from eav_attribute where attribute_code = 'url_key' and entity_type_id = @category_entity_type_id;
    SELECT @category_url_path_id := attribute_id from eav_attribute where attribute_code = 'url_path' and entity_type_id = @category_entity_type_id;

    WHILE @category_count < @category_limit DO

    SELECT @NEWID := AUTO_INCREMENT from information_schema.tables where table_name = 'catalog_category_entity';

    INSERT INTO catalog_category_entity (
    entity_type_id,
    attribute_set_id,
    parent_id,
    created_at,
    updated_at,
    path,
    position,
    level,
    children_count
    ) VALUES (
    @category_entity_type_id,
    @category_attribute_set_id,
    @ROOTCATEGORY,
    NOW(),
    NOW(),
    concat("1/2/", @NEWID),
    1,
    2,
    0
    );

    SELECT @category_entity_id := entity_id from catalog_category_entity order by entity_id desc limit 1;
    INSERT INTO catalog_category_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@include_in_menu,@category_entity_id,@INCLUDEINMENU);
    INSERT INTO catalog_category_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@is_active,@category_entity_id,@ISACTIVE);
    INSERT INTO catalog_category_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@category_url_key_id,@category_entity_id,concat(@CATURLKEYPREFIX, @category_count));
    INSERT INTO catalog_category_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@category_url_path_id,@category_entity_id,concat(@CATURLPATHPREFIX, @category_count));
    INSERT INTO catalog_category_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@category_entity_type_id,@category_name_id,@category_entity_id,concat(@CATNAMEPREFIX, @category_count));

    SET @category_count = @category_count + 1;
    END WHILE;


    SET @product_limit = 3;
    SET @product_count = 1;
    SET @NAMEPREFIX = "Test Product #";
    SET @URLKEYPREFIX = "key-";
    SET @URLPATHPREFIX = "path-";
    SET @SKUPREFIX = "sku-";
    SET @VISIBILITY = 4;
    SET @STATUS = 1;
    SET @TAXCLASS = 1;
    SET @MAXPRICE = 100;
    SET @MAXWEIGHT = 20;
    SET @DESCRIPTION = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
    SET @SHORTDESCRIPTION = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";

    SELECT @entity_type_id := entity_type_id from eav_entity_type where entity_type_code = 'catalog_product';
    SELECT @attribute_set_id := attribute_set_id from eav_attribute_set where attribute_set_name = 'Default' and entity_type_id = @entity_type_id;

    SELECT @visibility_id := attribute_id from eav_attribute where attribute_code = 'visibility' and entity_type_id = @entity_type_id;
    SELECT @status_id := attribute_id from eav_attribute where attribute_code = 'status' and entity_type_id = @entity_type_id;
    SELECT @taxclass_id := attribute_id from eav_attribute where attribute_code = 'tax_class_id' and entity_type_id = @entity_type_id;

    SELECT @description_id := attribute_id from eav_attribute where attribute_code = 'description' and entity_type_id = @entity_type_id;
    SELECT @short_description_id := attribute_id from eav_attribute where attribute_code = 'short_description' and entity_type_id = @entity_type_id;

    SELECT @price_id := attribute_id from eav_attribute where attribute_code = 'price' and entity_type_id = @entity_type_id;
    SELECT @weight_id := attribute_id from eav_attribute where attribute_code = 'weight' and entity_type_id = @entity_type_id;

    SELECT @name_id := attribute_id from eav_attribute where attribute_code = 'name' and entity_type_id = @entity_type_id;
    SELECT @url_key_id := attribute_id from eav_attribute where attribute_code = 'url_key' and entity_type_id = @entity_type_id;
    SELECT @url_path_id := attribute_id from eav_attribute where attribute_code = 'url_path' and entity_type_id = @entity_type_id;

    WHILE @product_count < @product_limit DO

    INSERT INTO catalog_product_entity (
    entity_type_id,
    attribute_set_id,
    type_id,
    sku,
    created_at,
    updated_at
    ) VALUES (
    @entity_type_id,
    @attribute_set_id,
    "simple",
    concat(@SKUPREFIX, @product_count),
    NOW(),
    NOW()
    );
    SELECT @entity_id := entity_id from catalog_product_entity order by entity_id desc limit 1;
    INSERT INTO catalog_product_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@visibility_id,@entity_id,@VISIBILITY);
    INSERT INTO catalog_product_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@status_id,@entity_id,@STATUS);
    INSERT INTO catalog_product_entity_int (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@taxclass_id,@entity_id,@TAXCLASS);
    INSERT INTO catalog_product_entity_text (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@description_id,@entity_id,@DESCRIPTION);
    INSERT INTO catalog_product_entity_text (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@short_description_id,@entity_id,@SHORTDESCRIPTION);
    INSERT INTO catalog_product_entity_decimal (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@price_id,@entity_id,ROUND(RAND(2) * @MAXPRICE,2));
    INSERT INTO catalog_product_entity_decimal (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@weight_id,@entity_id,ROUND(RAND(2) * @MAXWEIGHT,2));
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@url_key_id,@entity_id,concat(@URLKEYPREFIX, @product_count));
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@url_path_id,@entity_id,concat(@URLPATHPREFIX, @product_count));
    INSERT INTO catalog_product_entity_varchar (entity_type_id,attribute_id,entity_id,value) VALUES(@entity_type_id,@name_id,@entity_id,concat(@NAMEPREFIX, @product_count));
    SELECT @CATID := entity_id FROM catalog_category_entity WHERE parent_id = @ROOTCATEGORY ORDER BY RAND() LIMIT 1;
    INSERT INTO catalog_category_product (category_id,product_id,position) VALUES(@CATID,@entity_id,1);

    SET @product_count = @product_count + 1;
    END WHILE;
    end
    ;;