Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ImportExport bug which occurs while importing multiple rows per entity #542

Closed
wants to merge 1 commit into from
Closed

Fix ImportExport bug which occurs while importing multiple rows per entity #542

wants to merge 1 commit into from

Conversation

tim-bezhashvyly
Copy link

This pull request solves couple of bugs.

As you know Magento allows import of a complex data by splitting the entity information into multiple lines. So let's say I want to import 2 products like this:

sku,_store,_attribute_set,_type,_category,_root_category,_product_websites,activation_information,color,computer_manufacturers,contrast_ratio,cost,country_of_manufacture,country_orgin,cpu_speed,created_at,custom_design,custom_design_from,custom_design_to,custom_layout_update,description,dimension,finish,gallery,gender,gift_message_available,harddrive_speed,hardrive,has_options,image,image_label,in_depth,manufacturer,max_resolution,media_gallery,megapixels,memory,meta_description,meta_keyword,meta_title,minimal_price,model,msrp,msrp_display_actual_price_type,msrp_enabled,name,news_from_date,news_to_date,options_container,page_layout,price,processor,ram_size,required_options,response_time,room,screensize,shape,shirt_size,shoe_size,shoe_type,short_description,small_image,small_image_label,special_from_date,special_price,special_to_date,status,tax_class_id,thumbnail,thumbnail_label,updated_at,url_key,url_path,visibility,weight,qty,min_qty,use_config_min_qty,is_qty_decimal,backorders,use_config_backorders,min_sale_qty,use_config_min_sale_qty,max_sale_qty,use_config_max_sale_qty,is_in_stock,notify_stock_qty,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,stock_status_changed_auto,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,_links_related_sku,_links_related_position,_links_crosssell_sku,_links_crosssell_position,_links_upsell_sku,_links_upsell_position,_associated_sku,_associated_default_qty,_associated_position,_tier_price_website,_tier_price_customer_group,_tier_price_qty,_tier_price_price,_group_price_website,_group_price_customer_group,_group_price_price,_media_attribute_id,_media_image,_media_lable,_media_position,_media_is_disabled,_custom_option_store,_custom_option_type,_custom_option_title,_custom_option_is_required,_custom_option_price,_custom_option_sku,_custom_option_max_characters,_custom_option_sort_order,_custom_option_row_title,_custom_option_row_price,_custom_option_row_sku,_custom_option_row_sort,_super_products_sku,_super_attribute_code,_super_attribute_option,_super_attribute_price_corr
1111,,Furniture,simple,"Furniture/Living Room","Root Catalog",base,,Red,,,50.0000,,Italy,,"2007-08-28 16:25:46",,,,,"The Magento ottoman will impress with its style while it delivers on quality. This piece of living room furniture is built to last with durable solid wood framing, generous padding and plush stain-resistant microfiber upholstery.",,Microfiber,,,,,,0,/o/t/ottoman.jpg,,,,,,,,Ottoman,Ottoman,Ottoman,299.9900,magotto,,,,Ottoman,,,"Block after Info Column",,299.9900,,,0,,"Living Room",,,,,,"With durable solid wood framing, generous padding and plush stain-resistant microfiber upholstery.",/o/t/ottoman.jpg,,,,,1,2,/o/t/ottoman.jpg,,"2008-08-08 14:59:04",ottoman,ottoman.html,4,20.0000,706.0000,0.0000,1,0,0,1,1.0000,1,100.0000,1,1,,1,0,1,0,1,0.0000,1,0,0,1112,,384822,,1114,,,,,,,,,,,,703,/o/t/ottoman.jpg,,0,1,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,bar1234,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
1112,,Furniture,simple,"Some Non Existent Category","Root Catalog",base,,Red,,,50.0000,,Italy,,"2007-08-28 16:29:24",,,,,"This Magento chair features a fun, futuristic design, with fluid curves and gentle angles that follow the shape of the body to enhance ultimate relaxation. It combines a hint of nostalgia with the up-to-date sensibility and function of modern chairs. It is in soft, velvety microfiber.",,Microfiber,,,,,,0,/c/h/chair.jpg,,,,,,,,Chair,Chair,Chair,129.9900,1112,,,,Chair,,,"Block after Info Column",,129.9900,,,0,,"Living Room",,,,,,"Combining a hint of nostalgia with the up-to-date sensibility and function of modern chairs. It is in soft, velvety microfiber.",/c/h/chair.jpg,,,,,1,2,/c/h/chair.jpg,,"2008-08-08 14:59:17",chair,chair.html,4,50.0000,724.0000,0.0000,1,0,0,1,1.0000,1,100.0000,1,1,,1,0,1,0,1,0.0000,1,0,0,1113,,384822,,1114,,,,,,,,,,,,703,/c/h/chair.jpg,,0,1,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,n2610,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

As you can see the only purpose of the second rows (let's call them "slave" rows) for each product is to provide one more cross-selling connection.

The first problem happens when importer will try to process the "master" row of the second product (SKU = 1112). The validation of the row will fail. In our case it will happen because of non-existing category but the reason can be different. The importer will rightfully skip this row and move to "slave" row. This row will pass validation but as the previous row was ignored it will be assigned to earlier product with SKU = 1111. This means the cross-selling connection will be added to wrong product.

This becomes even worse threat for multilingual stores where products can get wrong names, images or other vital attributes.

This pull request is addressing this issue by grouping rows which belong to the same entity and pushing them into the bunch only if all rows of the group passed validation. Also if one row of the group fails validation the rest of the "slave" rows will not be even checked which will insignificantly speed up processing.

If user prefers importer to process the group regardless if it contains invalid rows he can achieve it by adding sku values along with other required values to each "slave" row.

The second bug is somehow alike. It is derived from the fact that importer will split large data sets into chunks (by default of 500 rows) and save them for future processing. The problem is that "slave" rows which are wrapped into the next bunch are ignored and lost.

This pull request is addressing this issue by closing the bunch only if the there are no more "slave" rows left. So each bunch will always start with a "master" row.

Both bugs above are extremely critical and resulted in my complete catalog of 200k SKUs to be messed up, sales loss and significant damage to the business.

@verklov verklov self-assigned this Apr 8, 2014
@verklov
Copy link
Contributor

verklov commented Apr 8, 2014

@tim-bezhashvyly, thank you for contributing your pull request! The team will look at it and we will get back to you once we have the answer.

magento-team added a commit that referenced this pull request May 27, 2014
* Tax calculation updates:
 * Fixed issues in tax calculation rounding with discount applied
 * Fixed an issue with extra penny  when exact tax amount ended with 0.5 cent
 * Fixed an issue where there were tax calculation errors when customer tax rate was different from store tax rate
 * Added support to round tax at individual tax rate
 * Fixed price inconsistencies between catalog and shopping cart
 * Added support for maintaining consistent price including tax for customers with different tax rates
 * Added support for applying tax rules with different priorities to subtotal only
* Fixed bugs:
  * Removed the extra '%' sign in the error\notice message on Gift Card Accounts page on the backend
  * Fixed an issue with image uploading functionality in the Catalog configuration
  * Fixed an issue where a customer could not navigate the store when downloading the downloadable product
  * Fixed an issue where adding CMS block Catalog Events Lister caused an error
  * Fixed an issue where the price was displayed twice on the Product page on the frontend
  * Fixed an issue where an admin could not open search results on the backend
  * Fixed an issue where the Rule Based Product Relations functionality was generating incorrect SQL when product category attribute was set through "is one of" or "contains" operator by constant value
  * Fixed an issue where it was impossible to add a product to the Compare list for  categories with three-column page layout
  * Fixed an issue where a blank page opened when changing store view on a product page on the frontend
  * Fixed an issue where the  "Please specify at least one search term." error message was not displayed if search is performed without search data specified on the frontend
  * Fixed a Google Chrome specific issue where page layout was broken when updating status for reviews on the backend
  * Fixed admin look and feel issues
  * Fixed an issue where the order notices and error messages were not red
  * Fixed a UI issue which appeared during custom attribute creation
  * Fixed an issue where the popup did not open after clicking What's this? next to the Remember Me check box  when persistent shopping cart was enabled
  * Fixed an issue where the options of the Add Product split dropdown did not fit the page
  * Fixed an issue where the default theme preview image sample link was missing
  * Fixed a Safari and Internet Explorer 9 specific issue where the backend menu is not displayed for users with custom admin roles
  * Fixed an issue where  the price of bundle products was not  displayed correctly on the product page on the frontend
  * Fixed a UI issue in the debug mode configuration
  * Fixed minor issues with page layout
  * Fixed an issue where the mini shopping cart loaded data from cache
  * Fixed an issue where there was an incorrect value in the Grand Total (Base) column in the Orders grid if Catalog Price Scope was set to Website
  * Fixed an issue where the Entity Generator tool did not accept the "class" parameter
  * Fixed an issue where the default email template was not applied when the custom template in use was deleted
  * Fixed an issue where shipping price for flat rate was set to 0 in the side block during checkout of a product with a configured recurring profile
  * Fixed an issue where it was possible to create more Shipping Labels than there were products in the shipment
  * Fixed an issue where data about "SHA-IN Pass Phrase" was missing after changing "Payment Action" in the Ogone payment method configuration
  * Fixed performance issues with reindexing of the Price indexer
  * Fixed an issue where importing tax rates with postal code = * led to incorrect data entered into database
  * Fixed an issue where incorrect link to reset password was sent if secure URL was used on the frontend
  * Fixed an issue where the Links section was absent while editing downloadable products from the Wishlist
  * Fixed an issue where specified details for composite products were lost after adding to Gift Card and Downloadable products to the Wishlist
  * Fixed and issue where the Date widget was set to incorrect date when creating a new customer
  * Fixed an issue where a customer was redirected to Dashboard if the Redirect user to dashboard after login option was set to No
  * Fixed an issue where a customer was not able to register during checkout if Guest Checkout was not allowed
  * Fixed an issue where System logs were not generated properly in integration tests
  * Fixed benchmarking script
  * Fixed an issue where it was impossible to put store to the maintenance mode during backup
  * Fixed insecure use of mt_rand()
  * Fixed an issue where Quoted price was displayed incorrectly from the shopping cart in the backend
* Functional tests:
  * Tax Rule Creation
  * Admin User Roe Creation
  * Simple Product Creation
  * Customer Group Creation
  * Update Backend Customer
  * Newsletter Creation
* Updated composer.json.dist to download and install MTF from Public GitHub repository
* GitHub requests:
  * [#542] (#542) Fix ImportExport bug which occurs while importing multiple rows per entity
  * [#507] (#507) "Insert Image" window is overlapped on menu
@tim-bezhashvyly
Copy link
Author

@verklov So you are not merging pull requests directly into your repo, right? Shall I kill mine then or how does it work?

@verklov
Copy link
Contributor

verklov commented May 28, 2014

@tim-bezhashvyly, you are right, we are not merging pull requests directly. Anyway, you should not kill your pull request. In any case it serves as a basis for us. The team reviews code contribution and then makes a decision whether to merge it as is or rewrite it being guided by the idea suggested or issue noted. In some cases though, the team agrees to the pull request being submitted and merges it as is.
In any case, when there is a code contribution available from the community member, this is a valuable thing the team can start working with. I hope this clarifies a bit the process we are following.

Meanwhile, this particular pull request was processed by the team and we released the fix in dev79 just yesterday. Thank you very much for your contribution! Looking forward for new bug reports and ideas from you, Tim!

@verklov verklov closed this May 28, 2014
magento-team added a commit that referenced this pull request Jun 27, 2014
* Fixed bugs:
  * Fixed an issue where an invalidly filled option did not become in focus after saving attempt on the Create New Order page in the backend
  * Fixed an issue with the default configuration not being applied properly in the CAPTCHA configuration section
  * Fixed an issue with optional State/Province fields on the Create New Order page being marked as required
  * Fixed an issue with incorrect Customer model usage on session in community modules
  * Fixed an issue where cache was not invalidated after applying catalog price rule
  * Fixed an issue where an admin with custom permissions could not create Shopping Cart Price Rule/Catalog Price Rule
  * Fixed an issue with REST request and response format being inconsistent
  * Fixed an issue where there was an error on a bundle product page if bundle items contained an out of stock product
  * Fixed a JS issue which appeared when adding associated products for a grouped product
  * Fixed an issue where layered navigation was absent on the Advanced Search results page
  * Fixed an issue where the leading "0" in numbers were truncated when exporting using Excel XML
  * Fixed the price type attribute filter in Layered Navigation
  * Fixed an issue with a fatal error in \Magento\Framework\ArchiveTest when bz2 extension was not installed
  * Fixed an issue where an admin could search product by attributes set on the Store View level (except default store view)
  * Fixed an issue where extra spaces in search values were not ignored during search and thus wrong search results were given
* GitHub requests:
  * [#542]  Fix ImportExport bug which occurs while importing multiple rows per entity
  * [#544]  Performance tests not working
* Framework improvements:
  * Covered the following Magento application components with unit tests:
      * `Customer/Model/Address.php`
      * `Customer/Model/Address/AbstractAddress.php `
      * `Customer/Model/Address/Converter.php`
      * `Customer/Model/Customer.php`
      * `Customer/Model/Customer/Attribute/Backend/Billing.php`
      * `Customer/Model/Customer/Attribute/Backend/Shipping.php`
      * `Customer/Model/Customer/Attribute/Backend/Store.php `
      * `Customer/Model/Customer/Attribute/Backend/Website.php `
      * `Customer/Model/Customer/Attribute/Backend/PasswordTest.php`
      * `Customer/Helper/Address.php`
      * `Customer/Helper/View.php`
      * `Customer/Service/V1/CustomerAccountService.php`
  * Covered Magento lib with unit tests:
      * `lib/internal/Magento/Framework/Filter/*`
      * `lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php`
      * `lib/internal/Magento/Framework/Model/Resource/Db/Collection/AbstractCollection.php`
      * `lib/internal/Magento/Framework/File/Uploader.php`
      * `lib/internal/Magento/Framework/File/Csv.php`
      * `lib/internal/Magento/Framework/Less/File/Collector/Aggregated.php`
      * `lib/internal/Magento/Framework/Less/File/Collector/Library.php`
      * `lib/internal/Magento/Framework/Locale/Config.php`
      * `lib/internal/Magento/Framework/Locale/Currency.php`
      * `lib/internal/Magento/Framework/App/Config/Element.php`
      * `lib/internal/Magento/Framework/App/Config/Value.php`
      * `lib/internal/Magento/Framework/App/DefaultPath/DefaultPath.php`
      * `lib/internal/Magento/Framework/App/EntryPoint/EntryPoint.php`
      * `lib/internal/Magento/Framework/App/Helper/AbstractHelper.php`
      * `lib/internal/Magento/Framework/App/Resource/ConnectionFactory.php`
      * `lib/internal/Magento/Framework/App/Route/Config.php`
  * Implemented the ability for a mobile client to get a partial response
  * Added authentication support for mobile
  * Refactored the Oauth lib exception not to reference module classes
  * Moved the authorization services according to the new directory format: was \Magento\Authz\Service\AuthorizationV1Interface, became \Magento\Authz\Service\V1\AuthorizationInterface
  * Moved the integration services according to the new directory format:
    * Was \Magento\Integration\Service\IntegrationV1, became \Magento\Integration\Service\V1\Integration
    * Was \Magento\Integration\Service\OauthV1, became \Magento\Integration\Service\V1\Oauth
  * Improved security of the integration registration
  * Introduced language packages with ability to inherit dictionaries
* Improved modularity of ImportExport
* Created Service API for Magento_Catalog module:
   * Implemented Product Attribute Media API
   * Implemented Product Group Price API
   * Implemented Product Attribute Write API
   * Implemented Product Attribute Options Read and Write API
* Created Service for the Magento Tax module:
  * Implemented Tax Rule Service
  * Implemented Tax Rate Service
  * Implemented Tax Calculation Data Objects
  * Implemented Tax Calculation Builders
  * Implemented Tax Calculation Service
* Covered the part of the Catalog Module with unit tests
* Added PayPall Bill Me Later button
* Streamlined checkout experience
* Improved order review page for PayPal Express Checkout
vpelipenko added a commit that referenced this pull request Sep 3, 2015
[Folks] MAGETWO-40559: [GITHUB] 1.0.0 Beta 1 JS Error when click 'Go to Checkout...
magento-team pushed a commit that referenced this pull request Apr 16, 2016
mmansoor-magento pushed a commit that referenced this pull request Oct 31, 2016
…te-configurable-product-with-child-by-REST-API-2.2

Fixed issue:
 - MAGETWO-58348 Cannot create configurable product with child by REST API
magento-devops-reposync-svc pushed a commit that referenced this pull request Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants