Magento 2: Overriding Sales Order DefaultRenderer (Order Items) The Next CEO of Stack OverflowOverriding SalesBlockOrderView Block in Magento 2Overriding class Magento 2.1Why Getting categories and names on product view page Magento 2 fails?Magento 2 Add new field to Magento_User admin formI have created an extension to show Customer Company Name in Order grid. But when creating new order, order is not showing in order gridMagento 2: Add a product to the cart programmaticallyMagento offline custom Payment method with drop down listMagento 2 Create dynamic array From different Model Collection to use in multi select in gridMagento 2.2.5: Overriding Admin Controller sales/orderMagento 2.3 Can't view module's front end page output?

Is this a new Fibonacci Identity?

Traveling with my 5 year old daughter (as the father) without the mother from Germany to Mexico

Find the majority element, which appears more than half the time

What difference does it make matching a word with/without a trailing whitespace?

Calculate the Mean mean of two numbers

Avoiding the "not like other girls" trope?

Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact

A hang glider, sudden unexpected lift to 25,000 feet altitude, what could do this?

Finitely generated matrix groups whose eigenvalues are all algebraic

Why do we say “un seul M” and not “une seule M” even though M is a “consonne”?

Is it okay to majorly distort historical facts while writing a fiction story?

Ising model simulation

Shortening a title without changing its meaning

How exploitable/balanced is this homebrew spell: Spell Permanency?

Does Germany produce more waste than the US?

How does a dynamic QR code work?

How can a day be of 24 hours?

What happens if you break a law in another country outside of that country?

Cannot restore registry to default in Windows 10?

Prodigo = pro + ago?

How can I prove that a state of equilibrium is unstable?

Calculating discount not working

Creating a script with console commands

Does the Idaho Potato Commission associate potato skins with healthy eating?



Magento 2: Overriding Sales Order DefaultRenderer (Order Items)



The Next CEO of Stack OverflowOverriding SalesBlockOrderView Block in Magento 2Overriding class Magento 2.1Why Getting categories and names on product view page Magento 2 fails?Magento 2 Add new field to Magento_User admin formI have created an extension to show Customer Company Name in Order grid. But when creating new order, order is not showing in order gridMagento 2: Add a product to the cart programmaticallyMagento offline custom Payment method with drop down listMagento 2 Create dynamic array From different Model Collection to use in multi select in gridMagento 2.2.5: Overriding Admin Controller sales/orderMagento 2.3 Can't view module's front end page output?










0















I'm trying to override the DefaultRenderer (commonly found when customer views their order in accounts) so I can do some customisations and include extra data.



I've managed to do this successfully, but when I view the order it doesn't show various bits of data which would normally appear without overriding. This includes item options, price, even SKU. It looks like this is anything with $block-> preceding it.



For example:



$block->prepareSku($block->getSku())



Gives me this error:



Invalid method VendorFancyOrderBlockItemInterceptor::prepareSku



If I remove this line, the order summary loads as expected, but with important information missing.



This is my block. I'm slowly getting used to module creation and dependency injection, so I have a feeling I've missed out some key things:



<?php
namespace VendorFancyOrderBlock;

use MagentoCatalogModelProduct;
use MagentoFrameworkExceptionLocalizedException;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewElementTemplate;

class Item extends Template


/**
* @var Registry
*/
protected $registry;
protected $_imageBuilder;
/**
* @var Product
*/
private $product;

public function __construct(TemplateContext $context,
Registry $registry,
MagentoCatalogHelperImage $imageHelper,
MagentoCatalogApiProductRepositoryInterfaceFactory $productRepositoryFactory,
array $data)

$this->registry = $registry;
$this->_imageHelper = $imageHelper;
$this->_productRepositoryFactory = $productRepositoryFactory;

parent::__construct($context, $data);


public function getTheImage($productID)

$product = $this->_productRepositoryFactory->create()->getById($productID);
//return $this->_imageHelper->init($product,'thumbnail')->setImageFile($product->getThumbnail())->getUrl();

$resized = $this->_imageHelper->init($product, 'product_small_image')
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepTransparency(TRUE)
->keepFrame(FALSE)
->resize(200, 300);
return $resized->getUrl();




I have a feeling I need to declare the class in a different way, but I'm not sure how. I tried Class Item extends MagentoSalesBlockOrderItemRenderer but that errors.



Any information may help :)



Thank you!










share|improve this question


























    0















    I'm trying to override the DefaultRenderer (commonly found when customer views their order in accounts) so I can do some customisations and include extra data.



    I've managed to do this successfully, but when I view the order it doesn't show various bits of data which would normally appear without overriding. This includes item options, price, even SKU. It looks like this is anything with $block-> preceding it.



    For example:



    $block->prepareSku($block->getSku())



    Gives me this error:



    Invalid method VendorFancyOrderBlockItemInterceptor::prepareSku



    If I remove this line, the order summary loads as expected, but with important information missing.



    This is my block. I'm slowly getting used to module creation and dependency injection, so I have a feeling I've missed out some key things:



    <?php
    namespace VendorFancyOrderBlock;

    use MagentoCatalogModelProduct;
    use MagentoFrameworkExceptionLocalizedException;
    use MagentoFrameworkRegistry;
    use MagentoFrameworkViewElementTemplate;

    class Item extends Template


    /**
    * @var Registry
    */
    protected $registry;
    protected $_imageBuilder;
    /**
    * @var Product
    */
    private $product;

    public function __construct(TemplateContext $context,
    Registry $registry,
    MagentoCatalogHelperImage $imageHelper,
    MagentoCatalogApiProductRepositoryInterfaceFactory $productRepositoryFactory,
    array $data)

    $this->registry = $registry;
    $this->_imageHelper = $imageHelper;
    $this->_productRepositoryFactory = $productRepositoryFactory;

    parent::__construct($context, $data);


    public function getTheImage($productID)

    $product = $this->_productRepositoryFactory->create()->getById($productID);
    //return $this->_imageHelper->init($product,'thumbnail')->setImageFile($product->getThumbnail())->getUrl();

    $resized = $this->_imageHelper->init($product, 'product_small_image')
    ->constrainOnly(TRUE)
    ->keepAspectRatio(TRUE)
    ->keepTransparency(TRUE)
    ->keepFrame(FALSE)
    ->resize(200, 300);
    return $resized->getUrl();




    I have a feeling I need to declare the class in a different way, but I'm not sure how. I tried Class Item extends MagentoSalesBlockOrderItemRenderer but that errors.



    Any information may help :)



    Thank you!










    share|improve this question
























      0












      0








      0








      I'm trying to override the DefaultRenderer (commonly found when customer views their order in accounts) so I can do some customisations and include extra data.



      I've managed to do this successfully, but when I view the order it doesn't show various bits of data which would normally appear without overriding. This includes item options, price, even SKU. It looks like this is anything with $block-> preceding it.



      For example:



      $block->prepareSku($block->getSku())



      Gives me this error:



      Invalid method VendorFancyOrderBlockItemInterceptor::prepareSku



      If I remove this line, the order summary loads as expected, but with important information missing.



      This is my block. I'm slowly getting used to module creation and dependency injection, so I have a feeling I've missed out some key things:



      <?php
      namespace VendorFancyOrderBlock;

      use MagentoCatalogModelProduct;
      use MagentoFrameworkExceptionLocalizedException;
      use MagentoFrameworkRegistry;
      use MagentoFrameworkViewElementTemplate;

      class Item extends Template


      /**
      * @var Registry
      */
      protected $registry;
      protected $_imageBuilder;
      /**
      * @var Product
      */
      private $product;

      public function __construct(TemplateContext $context,
      Registry $registry,
      MagentoCatalogHelperImage $imageHelper,
      MagentoCatalogApiProductRepositoryInterfaceFactory $productRepositoryFactory,
      array $data)

      $this->registry = $registry;
      $this->_imageHelper = $imageHelper;
      $this->_productRepositoryFactory = $productRepositoryFactory;

      parent::__construct($context, $data);


      public function getTheImage($productID)

      $product = $this->_productRepositoryFactory->create()->getById($productID);
      //return $this->_imageHelper->init($product,'thumbnail')->setImageFile($product->getThumbnail())->getUrl();

      $resized = $this->_imageHelper->init($product, 'product_small_image')
      ->constrainOnly(TRUE)
      ->keepAspectRatio(TRUE)
      ->keepTransparency(TRUE)
      ->keepFrame(FALSE)
      ->resize(200, 300);
      return $resized->getUrl();




      I have a feeling I need to declare the class in a different way, but I'm not sure how. I tried Class Item extends MagentoSalesBlockOrderItemRenderer but that errors.



      Any information may help :)



      Thank you!










      share|improve this question














      I'm trying to override the DefaultRenderer (commonly found when customer views their order in accounts) so I can do some customisations and include extra data.



      I've managed to do this successfully, but when I view the order it doesn't show various bits of data which would normally appear without overriding. This includes item options, price, even SKU. It looks like this is anything with $block-> preceding it.



      For example:



      $block->prepareSku($block->getSku())



      Gives me this error:



      Invalid method VendorFancyOrderBlockItemInterceptor::prepareSku



      If I remove this line, the order summary loads as expected, but with important information missing.



      This is my block. I'm slowly getting used to module creation and dependency injection, so I have a feeling I've missed out some key things:



      <?php
      namespace VendorFancyOrderBlock;

      use MagentoCatalogModelProduct;
      use MagentoFrameworkExceptionLocalizedException;
      use MagentoFrameworkRegistry;
      use MagentoFrameworkViewElementTemplate;

      class Item extends Template


      /**
      * @var Registry
      */
      protected $registry;
      protected $_imageBuilder;
      /**
      * @var Product
      */
      private $product;

      public function __construct(TemplateContext $context,
      Registry $registry,
      MagentoCatalogHelperImage $imageHelper,
      MagentoCatalogApiProductRepositoryInterfaceFactory $productRepositoryFactory,
      array $data)

      $this->registry = $registry;
      $this->_imageHelper = $imageHelper;
      $this->_productRepositoryFactory = $productRepositoryFactory;

      parent::__construct($context, $data);


      public function getTheImage($productID)

      $product = $this->_productRepositoryFactory->create()->getById($productID);
      //return $this->_imageHelper->init($product,'thumbnail')->setImageFile($product->getThumbnail())->getUrl();

      $resized = $this->_imageHelper->init($product, 'product_small_image')
      ->constrainOnly(TRUE)
      ->keepAspectRatio(TRUE)
      ->keepTransparency(TRUE)
      ->keepFrame(FALSE)
      ->resize(200, 300);
      return $resized->getUrl();




      I have a feeling I need to declare the class in a different way, but I'm not sure how. I tried Class Item extends MagentoSalesBlockOrderItemRenderer but that errors.



      Any information may help :)



      Thank you!







      magento2 product customer blocks






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 14 hours ago









      Thomas HardingThomas Harding

      283214




      283214




















          0






          active

          oldest

          votes












          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%2f268199%2fmagento-2-overriding-sales-order-defaultrenderer-order-items%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          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%2f268199%2fmagento-2-overriding-sales-order-defaultrenderer-order-items%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

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?