Developer view, please


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- <preference for="Magento\Catalog\Block\Product\View" type="Amf\GoogleAnalytics\Block\Catalog\Product\View" /> -->
<preference for="Magento\GoogleAnalytics\Block\Ga" type="YourCompany\YourModule\Block\Ga" />

Please let me know the best way

  1. copy files from vendor\magento\module-google-analytics\Block\Ga.php then modify the method.

  2. vendor\magento\module-google-analytics\Block\Ga.php - copy only required the method then do the modification.(code - https://textuploader.com/1a8x4)

Following point 1 error appears

Fatal error: Uncaught TypeError: Argument 4 passed to Magento\GoogleAnalytics\Block\Ga::__construct() must be of the type array, null given, called in app\code\YourCompany\YourModule\Block\Ga.php on line 57 and defined in vendor\magento\module-google-analytics\Block\Ga.php on line 45

Following point 2 block override done - just override method getOrdersTrackingCode() and getOrdersTrackingData

The solution for the issue mentioned here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.