Plugin wont set Stock level and status - Module wont fire on Product Load Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Observer not executing. Could use extra eyesmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2. Custom Attribute And Plugin in ModuleProduct image wont load and dropwon wont populateMagento 2.2.5: Overriding Admin Controller sales/orderHow can we get stock data in product listing via afterGetList plugin in Magento 2.2.3Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?Override product load via plugin

Is the Standard Deduction better than Itemized when both are the same amount?

Can I cast Passwall to drop an enemy into a 20-foot pit?

Fundamental Solution of the Pell Equation

Is there a node or combination of nodes that can take an average colour out of a single image?

Should I discuss the type of campaign with my players?

Output the ŋarâþ crîþ alphabet song without using (m)any letters

How to find all the available tools in macOS terminal?

Why is my conclusion inconsistent with the van't Hoff equation?

Align equal signs while including text over equalities

Is there a (better) way to access $wpdb results?

Why didn't this character "real die" when they blew their stack out in Altered Carbon?

Resolving to minmaj7

What exactly is a "Meth" in Altered Carbon?

How come Sam didn't become Lord of Horn Hill?

Bete Noir -- no dairy

How to bypass password on Windows XP account?

Apollo command module space walk?

Why was the term "discrete" used in discrete logarithm?

Using audio cues to encourage good posture

Dating a Former Employee

Why are there no cargo aircraft with "flying wing" design?

List *all* the tuples!

Overriding an object in memory with placement new

Why do people hide their license plates in the EU?



Plugin wont set Stock level and status - Module wont fire on Product Load



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Observer not executing. Could use extra eyesmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2. Custom Attribute And Plugin in ModuleProduct image wont load and dropwon wont populateMagento 2.2.5: Overriding Admin Controller sales/orderHow can we get stock data in product listing via afterGetList plugin in Magento 2.2.3Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?Override product load via plugin



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm trying to update a stock level and status via a seperate API, and will code that when I get this working, however, I'm struggling to even set the Stock status and count to update based on information I've found on the net.



I need to run this before the product loads, as the product will most likely update and I need the screen to show the correct information. I want to use a product object as I might actually do some update on custom fields too, but for now, I'm starting simple, so any advice would be good.



UPDATE:



So I've gone done the module route, and it doesn't look like my module is firing, here is the files in the module. What kind of debugging can I use? or can anyone see anything obvious:



/app/code/Olisco/Tpcconnector/etc/di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogHelperProduct">
<plugin name="calltpc" type="OliscoTpcconnectorPluginApiCall" sortOrder="1" disabled="false"/>
</type>
</config>


/app/code/Olisco/Tpcconnector/Plugin/ApiCall.php



<?php
namespace OliscoTpcconnectorPlugin;

class ApiCall


public function beforeinitProduct(MagentoCatalogHelperProduct $subject, $result)


error_log("TEST");
var_dump("TEST");
echo "#########";
curl_setopt($ch, CURLOPT_URL, "https://dealer.theperformance.co/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

return $result;












share|improve this question



















  • 2





    you should not use events to update data. use plugins instead

    – Philipp Sander
    Apr 4 at 7:09











  • you are not saving the product

    – Philipp Sander
    Apr 4 at 7:10











  • @PhilippSander tried the ->save too and it made no difference.

    – Toby Lockyer
    Apr 4 at 7:13











  • @Toby Lockyer does your events.xml is under etc/frontend folder?

    – Kirill Korushkin
    Apr 4 at 7:26


















1















I'm trying to update a stock level and status via a seperate API, and will code that when I get this working, however, I'm struggling to even set the Stock status and count to update based on information I've found on the net.



I need to run this before the product loads, as the product will most likely update and I need the screen to show the correct information. I want to use a product object as I might actually do some update on custom fields too, but for now, I'm starting simple, so any advice would be good.



UPDATE:



So I've gone done the module route, and it doesn't look like my module is firing, here is the files in the module. What kind of debugging can I use? or can anyone see anything obvious:



/app/code/Olisco/Tpcconnector/etc/di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogHelperProduct">
<plugin name="calltpc" type="OliscoTpcconnectorPluginApiCall" sortOrder="1" disabled="false"/>
</type>
</config>


/app/code/Olisco/Tpcconnector/Plugin/ApiCall.php



<?php
namespace OliscoTpcconnectorPlugin;

class ApiCall


public function beforeinitProduct(MagentoCatalogHelperProduct $subject, $result)


error_log("TEST");
var_dump("TEST");
echo "#########";
curl_setopt($ch, CURLOPT_URL, "https://dealer.theperformance.co/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

return $result;












share|improve this question



















  • 2





    you should not use events to update data. use plugins instead

    – Philipp Sander
    Apr 4 at 7:09











  • you are not saving the product

    – Philipp Sander
    Apr 4 at 7:10











  • @PhilippSander tried the ->save too and it made no difference.

    – Toby Lockyer
    Apr 4 at 7:13











  • @Toby Lockyer does your events.xml is under etc/frontend folder?

    – Kirill Korushkin
    Apr 4 at 7:26














1












1








1


1






I'm trying to update a stock level and status via a seperate API, and will code that when I get this working, however, I'm struggling to even set the Stock status and count to update based on information I've found on the net.



I need to run this before the product loads, as the product will most likely update and I need the screen to show the correct information. I want to use a product object as I might actually do some update on custom fields too, but for now, I'm starting simple, so any advice would be good.



UPDATE:



So I've gone done the module route, and it doesn't look like my module is firing, here is the files in the module. What kind of debugging can I use? or can anyone see anything obvious:



/app/code/Olisco/Tpcconnector/etc/di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogHelperProduct">
<plugin name="calltpc" type="OliscoTpcconnectorPluginApiCall" sortOrder="1" disabled="false"/>
</type>
</config>


/app/code/Olisco/Tpcconnector/Plugin/ApiCall.php



<?php
namespace OliscoTpcconnectorPlugin;

class ApiCall


public function beforeinitProduct(MagentoCatalogHelperProduct $subject, $result)


error_log("TEST");
var_dump("TEST");
echo "#########";
curl_setopt($ch, CURLOPT_URL, "https://dealer.theperformance.co/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

return $result;












share|improve this question
















I'm trying to update a stock level and status via a seperate API, and will code that when I get this working, however, I'm struggling to even set the Stock status and count to update based on information I've found on the net.



I need to run this before the product loads, as the product will most likely update and I need the screen to show the correct information. I want to use a product object as I might actually do some update on custom fields too, but for now, I'm starting simple, so any advice would be good.



UPDATE:



So I've gone done the module route, and it doesn't look like my module is firing, here is the files in the module. What kind of debugging can I use? or can anyone see anything obvious:



/app/code/Olisco/Tpcconnector/etc/di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogHelperProduct">
<plugin name="calltpc" type="OliscoTpcconnectorPluginApiCall" sortOrder="1" disabled="false"/>
</type>
</config>


/app/code/Olisco/Tpcconnector/Plugin/ApiCall.php



<?php
namespace OliscoTpcconnectorPlugin;

class ApiCall


public function beforeinitProduct(MagentoCatalogHelperProduct $subject, $result)


error_log("TEST");
var_dump("TEST");
echo "#########";
curl_setopt($ch, CURLOPT_URL, "https://dealer.theperformance.co/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

return $result;









magento2 event-observer plugin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 mins ago







Toby Lockyer

















asked Apr 4 at 6:58









Toby LockyerToby Lockyer

61




61







  • 2





    you should not use events to update data. use plugins instead

    – Philipp Sander
    Apr 4 at 7:09











  • you are not saving the product

    – Philipp Sander
    Apr 4 at 7:10











  • @PhilippSander tried the ->save too and it made no difference.

    – Toby Lockyer
    Apr 4 at 7:13











  • @Toby Lockyer does your events.xml is under etc/frontend folder?

    – Kirill Korushkin
    Apr 4 at 7:26













  • 2





    you should not use events to update data. use plugins instead

    – Philipp Sander
    Apr 4 at 7:09











  • you are not saving the product

    – Philipp Sander
    Apr 4 at 7:10











  • @PhilippSander tried the ->save too and it made no difference.

    – Toby Lockyer
    Apr 4 at 7:13











  • @Toby Lockyer does your events.xml is under etc/frontend folder?

    – Kirill Korushkin
    Apr 4 at 7:26








2




2





you should not use events to update data. use plugins instead

– Philipp Sander
Apr 4 at 7:09





you should not use events to update data. use plugins instead

– Philipp Sander
Apr 4 at 7:09













you are not saving the product

– Philipp Sander
Apr 4 at 7:10





you are not saving the product

– Philipp Sander
Apr 4 at 7:10













@PhilippSander tried the ->save too and it made no difference.

– Toby Lockyer
Apr 4 at 7:13





@PhilippSander tried the ->save too and it made no difference.

– Toby Lockyer
Apr 4 at 7:13













@Toby Lockyer does your events.xml is under etc/frontend folder?

– Kirill Korushkin
Apr 4 at 7:26






@Toby Lockyer does your events.xml is under etc/frontend folder?

– Kirill Korushkin
Apr 4 at 7:26











1 Answer
1






active

oldest

votes


















1














If you are modifying the data, then you should use plugins and not the observers.



You can try creating the after plugin for the method initProduct of class MagentoCatalogHelperProduct



Reference Link for using Plugins : https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html






share|improve this answer























  • Perfect. I would prefer to do it properly. This makes more sense...

    – Toby Lockyer
    Apr 4 at 7:24











  • This example looks about right too....emiprotechnologies.com/technical_notes/…

    – Toby Lockyer
    Apr 4 at 7:24












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268697%2fplugin-wont-set-stock-level-and-status-module-wont-fire-on-product-load%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














If you are modifying the data, then you should use plugins and not the observers.



You can try creating the after plugin for the method initProduct of class MagentoCatalogHelperProduct



Reference Link for using Plugins : https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html






share|improve this answer























  • Perfect. I would prefer to do it properly. This makes more sense...

    – Toby Lockyer
    Apr 4 at 7:24











  • This example looks about right too....emiprotechnologies.com/technical_notes/…

    – Toby Lockyer
    Apr 4 at 7:24
















1














If you are modifying the data, then you should use plugins and not the observers.



You can try creating the after plugin for the method initProduct of class MagentoCatalogHelperProduct



Reference Link for using Plugins : https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html






share|improve this answer























  • Perfect. I would prefer to do it properly. This makes more sense...

    – Toby Lockyer
    Apr 4 at 7:24











  • This example looks about right too....emiprotechnologies.com/technical_notes/…

    – Toby Lockyer
    Apr 4 at 7:24














1












1








1







If you are modifying the data, then you should use plugins and not the observers.



You can try creating the after plugin for the method initProduct of class MagentoCatalogHelperProduct



Reference Link for using Plugins : https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html






share|improve this answer













If you are modifying the data, then you should use plugins and not the observers.



You can try creating the after plugin for the method initProduct of class MagentoCatalogHelperProduct



Reference Link for using Plugins : https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 4 at 7:15









Anshu MishraAnshu Mishra

5,67152662




5,67152662












  • Perfect. I would prefer to do it properly. This makes more sense...

    – Toby Lockyer
    Apr 4 at 7:24











  • This example looks about right too....emiprotechnologies.com/technical_notes/…

    – Toby Lockyer
    Apr 4 at 7:24


















  • Perfect. I would prefer to do it properly. This makes more sense...

    – Toby Lockyer
    Apr 4 at 7:24











  • This example looks about right too....emiprotechnologies.com/technical_notes/…

    – Toby Lockyer
    Apr 4 at 7:24

















Perfect. I would prefer to do it properly. This makes more sense...

– Toby Lockyer
Apr 4 at 7:24





Perfect. I would prefer to do it properly. This makes more sense...

– Toby Lockyer
Apr 4 at 7:24













This example looks about right too....emiprotechnologies.com/technical_notes/…

– Toby Lockyer
Apr 4 at 7:24






This example looks about right too....emiprotechnologies.com/technical_notes/…

– Toby Lockyer
Apr 4 at 7:24


















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268697%2fplugin-wont-set-stock-level-and-status-module-wont-fire-on-product-load%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?

Тонконіг бульбистий Зміст Опис | Поширення | Екологія | Господарське значення | Примітки | Див. також | Література | Джерела | Посилання | Навігаційне меню1114601320038-241116202404kew-435458Poa bulbosaЭлектронный каталог сосудистых растений Азиатской России [Електронний каталог судинних рослин Азіатської Росії]Малышев Л. Л. Дикие родичи культурных растений. Poa bulbosa L. - Мятлик луковичный. [Малишев Л. Л. Дикі родичи культурних рослин. Poa bulbosa L. - Тонконіг бульбистий.]Мятлик (POA) Сем. Злаки (Мятликовые) [Тонконіг (POA) Род. Злаки (Тонконогові)]Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Description from Flora of China) [Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Опис від Флора Китаю)]Poa bulbosa L. – lipnice cibulkatá / lipnica cibulkatáPoa bulbosa в базі даних Poa bulbosa на сайті Poa bulbosa в базі даних «Global Biodiversity Information Facility» (GBIF)Poa bulbosa в базі даних «Euro + Med PlantBase» — інформаційному ресурсі для Євро-середземноморського розмаїття рослинPoa bulbosa L. на сайті «Плантариум»

Вунгтау (аеропорт) Загальні відомості | Див. також | Посилання | Навігаційне меню10°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.0833310°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.083337731608Vinh AirportVinh airport facelift improves serviceвиправивши або дописавши їївиправивши або дописавши їїр