Skip to content

Fix #8820 #8171 [backport 2.2] check typeId on product save #11645

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

Closed
wants to merge 3 commits into from

Conversation

gomencal
Copy link
Contributor

@gomencal gomencal commented Oct 23, 2017

#8820 #8171
When saving a product, check typeId control. If it's value isn't one of available, set the default one before saving.

Description

Set the default product type before saving it on repository, for prevent error on create stockitem and the undesired attributes deleting on \Magento\Catalog\Model\Product\Type\AbstractType::_removeNotApplicableAttributes()

Fixed Issues

  1. WEBAPI: Unable to save Product when typeId and status is missing(Magento 2.1.5.) #8820: WEBAPI: Unable to save Product when typeId and status is missing
  2. magento/magento2#8171 Price not saved when creating product via REST API

Manual testing scenarios

Same testing described at issues #8820 and #8171. Save product via API.

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 on Travis CI are green)

@orlangur orlangur self-assigned this Oct 23, 2017
@orlangur orlangur added this to the October 2017 milestone Oct 24, 2017
@orlangur orlangur added Release Line: 2.2 2.2.x Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 24, 2017
@gomencal gomencal changed the title Fix #8820 [Backport 2.2] check typeId on product save Fix #8820 #8171 [backport 2.2] check typeId on product save Oct 26, 2017
@okorshenko okorshenko modified the milestones: October 2017, November 2017 Nov 1, 2017
@magento-engcom-team magento-engcom-team added bugfix Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog labels Nov 7, 2017
@@ -326,6 +326,10 @@ private function cacheProduct($cacheKey, \Magento\Catalog\Api\Data\ProductInterf
*/
protected function initializeProductData(array $productData, $createNew)
{
if (empty($productData['type_id'])) {
$productData['type_id'] = \Magento\Catalog\Model\Product\Type::DEFAULT_TYPE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @gomencal,

So, we don't have any kind of schema validation for WebAPI, right? Like a way to forbid empty type_id.

Where exactly error occurs in case of empty type_id? Maybe it's better to put such assignment there instead of repository?

@orlangur
Copy link
Contributor

Closing due to inactivity. @gomencal, feel free to reach me out anytime later if you wish to continue work on this pull request and it will be reopened.

@orlangur orlangur closed this Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Progress: needs update Release Line: 2.2 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants