Search code examples
productshopware

How can i Override file engine/Shopware/Core/sArticles.php in Shopware?


I want to override sSaveComment function in Shopware engine/Shopware/Core/sArticles.php

since i want to replace at the place of (1 to 10 ) to (1 star , 2stars ,3stars) etc .

enter image description here


Solution

  • Changing the logic of functions is only possible with a custom plugin. Since this function has no events, it is only possible to change this function with a hook. There are three possible ways:

    • BeforeHook: Changing the data that is passed to the function
    • ReplaceHook: Replace the entire function with your custom logic
    • AfterHook: Changing the return values of that function

    You can also use the hooks to make some custom things when the function is called (before/after).

    But I guess it would be better (because of compatibility reasons) to change the appearance in the frontend. Changing the whole logic might cause incompatibilities with other extensions. Change the dropdown in frontend/detail/comment/form.tpl and use only values like 2,4,6,8,10...