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

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form