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 Rest-API updating product stock_item deletes downloadable product data #28799

Merged
merged 4 commits into from
Jul 16, 2020

Conversation

engcom-Charlie
Copy link
Contributor

Description (*)

Fixed and covered by test

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Rest-API updating product stock_item deletes downloadable_product_links #21811

Manual testing scenarios (*)

See #21811

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jun 18, 2020

Hi @engcom-Charlie. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

@engcom-Charlie
Copy link
Contributor Author

@magento run all tests

Copy link
Contributor

@Stepa4man Stepa4man left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @engcom-Charlie
Thanks for your contribution

Please add to all changed files

    declare(strict_types=1);

You can read more here

I would also ask you to add type declaration everywhere in files you changed and replace object declaration with a more precise type.

@engcom-Charlie
Copy link
Contributor Author

@magento run all tests

@Stepa4man
Copy link
Contributor

@magento run all tests

@magento-engcom-team
Copy link
Contributor

Hi @Stepa4man, thank you for the review.
ENGCOM-7715 has been created to process this Pull Request
✳️ @Stepa4man, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@engcom-Delta
Copy link
Contributor

✔️ QA passed
Manual testing scenario:

  • Create regular downloadable product, upload downloadable content
  • Update product stock_item values using a PUT call: V1/products/{sku}
    { "product": { "sku": "Download1", "status": "1", "name": "Test Name", "price": "99.99", "type_id": "downloadable", "extension_attributes": { "stock_item": { "manage_stock": false } } } }
  • Go to downloadable product in admin panel

Before:

  • product has no links to download content (no downloadable information)

#28799Main
Response:

    "id": 1,
    "sku": "Download1",
    "name": "Test Name",
    "attribute_set_id": 4,
    "price": 9.99,
    "status": 1,
    "visibility": 4,
    "type_id": "downloadable",
    "created_at": "2020-06-25 12:36:24",
    "updated_at": "2020-06-25 13:15:53",
    "extension_attributes": {
        "website_ids": [
            1
        ],
        "category_links": [
            {
                "position": 0,
                "category_id": "3"
            }
        ],
        "stock_item": {
            "item_id": 1,
            "product_id": 1,
            "stock_id": 1,
            "qty": 1000,
            "is_in_stock": true,
            "is_qty_decimal": false,
            "show_default_notification_message": false,
            "use_config_min_qty": true,
            "min_qty": 0,
            "use_config_min_sale_qty": 1,
            "min_sale_qty": 1,
            "use_config_max_sale_qty": true,
            "max_sale_qty": 10000,
            "use_config_backorders": true,
            "backorders": 0,
            "use_config_notify_stock_qty": true,
            "notify_stock_qty": 1,
            "use_config_qty_increments": true,
            "qty_increments": 0,
            "use_config_enable_qty_inc": true,
            "enable_qty_increments": false,
            "use_config_manage_stock": true,
            "manage_stock": true,
            "low_stock_date": null,
            "is_decimal_divided": false,
            "stock_status_changed_auto": 0
        }
    },
    "options": [],
    "media_gallery_entries": [],
    "custom_attributes": [
        {
            "attribute_code": "options_container",
            "value": "container2"
        },
        {
            "attribute_code": "url_key",
            "value": "download1"
        },
        {
            "attribute_code": "msrp_display_actual_price_type",
            "value": "0"
        },
        {
            "attribute_code": "gift_message_available",
            "value": "2"
        },
        {
            "attribute_code": "required_options",
            "value": "0"
        },
        {
            "attribute_code": "has_options",
            "value": "0"
        },
        {
            "attribute_code": "meta_title",
            "value": "Download1"
        },
        {
            "attribute_code": "meta_keyword",
            "value": "Download1"
        },
        {
            "attribute_code": "meta_description",
            "value": "Download1 "
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        },
        {
            "attribute_code": "category_ids",
            "value": [
                "3"
            ]
        },
        {
            "attribute_code": "links_purchased_separately",
            "value": "0"
        },
        {
            "attribute_code": "samples_title",
            "value": "Samples"
        },
        {
            "attribute_code": "links_title",
            "value": "Links"
        }
    ]
}

✔️ After:

  • downloadable product links and samples are preserved

#28799PR
Response:

    "id": 1,
    "sku": "Download1",
    "name": "Test Name",
    "attribute_set_id": 4,
    "price": 99.99,
    "status": 1,
    "visibility": 4,
    "type_id": "downloadable",
    "created_at": "2020-06-25 12:36:24",
    "updated_at": "2020-06-25 13:02:08",
    "extension_attributes": {
        "website_ids": [
            1
        ],
        "category_links": [
            {
                "position": 0,
                "category_id": "3"
            }
        ],
        "stock_item": {
            "item_id": 1,
            "product_id": 1,
            "stock_id": 1,
            "qty": 1000,
            "is_in_stock": true,
            "is_qty_decimal": false,
            "show_default_notification_message": false,
            "use_config_min_qty": true,
            "min_qty": 0,
            "use_config_min_sale_qty": 1,
            "min_sale_qty": 1,
            "use_config_max_sale_qty": true,
            "max_sale_qty": 10000,
            "use_config_backorders": true,
            "backorders": 0,
            "use_config_notify_stock_qty": true,
            "notify_stock_qty": 1,
            "use_config_qty_increments": true,
            "qty_increments": 0,
            "use_config_enable_qty_inc": true,
            "enable_qty_increments": false,
            "use_config_manage_stock": true,
            "manage_stock": true,
            "low_stock_date": null,
            "is_decimal_divided": false,
            "stock_status_changed_auto": 0
        },
        "downloadable_product_links": [
            {
                "id": 2,
                "title": "Test Link",
                "sort_order": 1,
                "is_shareable": 1,
                "price": 0,
                "number_of_downloads": 0,
                "link_type": "file",
                "link_file": "/t/e/test.txt",
                "sample_type": "file",
                "sample_file": "/t/e/test.txt"
            }
        ]
    },
    "options": [],
    "media_gallery_entries": [],
    "custom_attributes": [
        {
            "attribute_code": "options_container",
            "value": "container2"
        },
        {
            "attribute_code": "url_key",
            "value": "download1"
        },
        {
            "attribute_code": "msrp_display_actual_price_type",
            "value": "0"
        },
        {
            "attribute_code": "gift_message_available",
            "value": "2"
        },
        {
            "attribute_code": "required_options",
            "value": "0"
        },
        {
            "attribute_code": "has_options",
            "value": "0"
        },
        {
            "attribute_code": "meta_title",
            "value": "Download1"
        },
        {
            "attribute_code": "meta_keyword",
            "value": "Download1"
        },
        {
            "attribute_code": "meta_description",
            "value": "Download1 "
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        },
        {
            "attribute_code": "category_ids",
            "value": [
                "3"
            ]
        },
        {
            "attribute_code": "links_purchased_separately",
            "value": "0"
        },
        {
            "attribute_code": "samples_title",
            "value": "Samples"
        },
        {
            "attribute_code": "links_title",
            "value": "Links"
        }
    ]
}

@engcom-Echo engcom-Echo self-assigned this Jun 25, 2020
@engcom-Echo engcom-Echo added the QA: Ready to add to Regression Scope Should be analyzed and added to Regression Testing Scope(if applicable) label Jun 26, 2020
@slavvka slavvka added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Jun 26, 2020
@slavvka slavvka added this to the 2.4.1 milestone Jun 26, 2020
@engcom-Delta engcom-Delta added QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope and removed QA: Ready to add to Regression Scope Should be analyzed and added to Regression Testing Scope(if applicable) labels Jun 30, 2020
@magento-engcom-team magento-engcom-team merged commit 7ca21b6 into magento:2.4-develop Jul 16, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jul 16, 2020

Hi @engcom-Charlie, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Downloadable Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Rest-API updating product stock_item deletes downloadable_product_links
6 participants