{"action":"created","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/13639","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/13639/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/13639/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/13639/events","html_url":"https://github.com/magento/magento2/issues/13639","id":296736645,"number":13639,"title":"2.2 : When saving a product using the product repository, the price is not saved","user":{"login":"kanduvisla","id":346681,"avatar_url":"https://avatars0.githubusercontent.com/u/346681?v=4","gravatar_id":"","url":"https://api.github.com/users/kanduvisla","html_url":"https://github.com/kanduvisla","followers_url":"https://api.github.com/users/kanduvisla/followers","following_url":"https://api.github.com/users/kanduvisla/following{/other_user}","gists_url":"https://api.github.com/users/kanduvisla/gists{/gist_id}","starred_url":"https://api.github.com/users/kanduvisla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kanduvisla/subscriptions","organizations_url":"https://api.github.com/users/kanduvisla/orgs","repos_url":"https://api.github.com/users/kanduvisla/repos","events_url":"https://api.github.com/users/kanduvisla/events{/privacy}","received_events_url":"https://api.github.com/users/kanduvisla/received_events","type":"User","site_admin":false},"labels":[{"id":688811200,"url":"https://api.github.com/repos/magento/magento2/labels/G1%20Passed","name":"G1 Passed","color":"0e8a16","default":false},{"id":686420665,"url":"https://api.github.com/repos/magento/magento2/labels/G2%20Passed","name":"G2 Passed","color":"0e8a16","default":false},{"id":686476746,"url":"https://api.github.com/repos/magento/magento2/labels/G3%20Passed","name":"G3 Passed","color":"0e8a16","default":false},{"id":686477126,"url":"https://api.github.com/repos/magento/magento2/labels/Reproduced%20on%202.2.x","name":"Reproduced on 2.2.x","color":"e99695","default":false},{"id":686477167,"url":"https://api.github.com/repos/magento/magento2/labels/Reproduced%20on%202.3.x","name":"Reproduced on 2.3.x","color":"e99695","default":false},{"id":21716835,"url":"https://api.github.com/repos/magento/magento2/labels/acknowledged","name":"acknowledged","color":"02d7e1","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-13T13:28:32Z","updated_at":"2018-02-14T08:15:07Z","closed_at":null,"author_association":"NONE","body":"I'm trying to programmatically create a product, but upon the first save, the price is not saved, thus returning 'NULL'. On a second save (with the identical object), the price gets saved.\r\n\r\n### Preconditions\r\n\r\n1. Magento 2.2 \r\n\r\n### Steps to reproduce\r\n\r\n    /** @var \\Magento\\Catalog\\Model\\Product $product */\r\n    $product = $this->productFactory->create();\r\n    $product->setSku('abc');\r\n    $product->setName('Name');\r\n    $product->setPrice(9.95);\r\n    $product->setAttributeSetId(4);\r\n\r\n    // Save once, the price does not get saved:\r\n    $this->productRepository->save($product);\r\n\r\n    // Check if the product is saved:\r\n    $product = $this->productRepository->get('abc');\r\n    $this->assertEquals('abc', $product->getSku());          // passes\r\n    $this->assertEquals('Name', $product->getName());  // passes\r\n    $this->assertEquals(9.95, $product->getPrice());  // fails (null does not equal 9.95\r\n\r\nWhen I add an extra `save()`-instruction it works:\r\n\r\n    // Save twice, the price gets saved:\r\n    $this->productRepository->save($product);\r\n    $this->productRepository->save($product);\r\n\r\n### Expected result\r\n\r\nThe price should be saved in the first run\r\n\r\n### Actual result\r\n\r\nThe price only gets saved the second time the `save()`-method is executed"},"comment":{"url":"https://api.github.com/repos/magento/magento2/issues/comments/365527822","html_url":"https://github.com/magento/magento2/issues/13639#issuecomment-365527822","issue_url":"https://api.github.com/repos/magento/magento2/issues/13639","id":365527822,"user":{"login":"kanduvisla","id":346681,"avatar_url":"https://avatars0.githubusercontent.com/u/346681?v=4","gravatar_id":"","url":"https://api.github.com/users/kanduvisla","html_url":"https://github.com/kanduvisla","followers_url":"https://api.github.com/users/kanduvisla/followers","following_url":"https://api.github.com/users/kanduvisla/following{/other_user}","gists_url":"https://api.github.com/users/kanduvisla/gists{/gist_id}","starred_url":"https://api.github.com/users/kanduvisla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kanduvisla/subscriptions","organizations_url":"https://api.github.com/users/kanduvisla/orgs","repos_url":"https://api.github.com/users/kanduvisla/repos","events_url":"https://api.github.com/users/kanduvisla/events{/privacy}","received_events_url":"https://api.github.com/users/kanduvisla/received_events","type":"User","site_admin":false},"created_at":"2018-02-14T08:15:07Z","updated_at":"2018-02-14T08:15:07Z","author_association":"NONE","body":"I've found another strange behavior with this:\r\n\r\nUpon the second save, the `catalog_product_entity_xxx`-tables are populated with duplicate values for every store view. So to recap:\r\n\r\n- Single save does save for store ID `0`, but does not save the price.\r\n- Second save saves duplicate values for every store view.\r\n\r\nEven if I explicitly use `setStoreId(0)`, the (duplicate) values get saved for all store views."}}
{"actor":{"display_login":"kanduvisla"}}