5

Till today all the code was okay, but after code review, I got that we use the method

load() on the store itself so I replaced it with

storeRepository->get($code)

Code what I'm talking about first fetched by load() then created the new entity by factory if it wasn't found. Right now after replacement, a problem occurred - method get() in storeRepository injects itself StoreFactory to create new store if it's not found, the problem is it fetches it from config,

but is it standard core_config_data Config ? If so, what parameters I should write to that config and what arguments in method save() of configuration should be used?

  • Can you update your full code? – Sukumar Gorai Sep 25 '18 at 8:45
  • @SukumarGorai Actually I'm testing some other approach if so I will provide text explanation. Can't post code since my Company Privacy Policy forbidden me to do so. – Jarzebowsky Sep 25 '18 at 8:47
  • So as I came to apporach where it's usable the best way is to replace $model->load() with $resourceModel->load() and if it's not returning id create it with factory and save with $resourceModel->save($factory) or just get $storeRepository->get($code) with Try catch block and validate exception the method returns to create new entity with factory and save as above. – Jarzebowsky Sep 25 '18 at 9:16
  • Should I provide it as answer and mark it as solved? Couldn't update. – Jarzebowsky Sep 25 '18 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.