title: Upsell product prices missing in Magento 2 when block loaded with AJAX
body: <p>I am working on a Magento 2 module that uses AJAX to load the upsell products. The upsell products can be different per customer so AJAX is used to load the block to allow for cache busting. </p>
  
  <p>For this I have a custom module where my block extends the <code>\Magento\Catalog\Block\Product\ProductList\Upsell</code>. In the modules layout for <code>catalog_product_view.xml</code> I have the following - </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"&gt;
      &lt;body&gt;
          &lt;referenceBlock name="product.info.upsell" remove="true" /&gt;
          &lt;referenceContainer name="content.aside"&gt;
              &lt;block class="MyCompany\MyModule\Block\Product\ProductList\Upsell"
                     name="personalised.product.upsell"
                     template="MyCompany_MyModule::upsell.phtml" /&gt;
          &lt;/referenceContainer&gt;
      &lt;/body&gt;
  &lt;/page&gt;
  </code></pre>
  
  <p>In my upsell.phtml -</p>
  
  <pre><code>&lt;div id="personalised-upsells-container" data-role="personalised-upsells"&gt;&lt;/div&gt;
  &lt;script type="text/x-magento-init"&gt;
      {
          "*": {
              "MyCompany_MyModule/js/upsell": {
                  "upsellAjaxUrl": "&lt;?php echo $block-&gt;getUpsellAjaxUrl(); ?&gt;"
              }
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>The <code>getUpsellAjaxUrl()</code> generates <code>http://magento2.dev/personalised/products/upsellAjax/id/6</code></p>
  
  <p>My upsell.js - </p>
  
  <pre><code>define([
      'jquery',
      'upsellProducts'
  ], function($) {
  
      function getUpsellContent(url) {
          $.ajax({
              url: url,
              dataType: 'html'
          }).done(function (data) {
              $('#personalised-upsells-container').html(data).promise().done(function(){
                  $('.upsell').upsellProducts();
              });
          });
      }
  
      return function (config, element) {
          getUpsellContent(config.upsellAjaxUrl);
      };
  });
  </code></pre>
  
  <p>My controller (upsellAjax) - </p>
  
  <pre><code>class UpsellAjax extends ProductController
  {
      public function execute()
      {
          $productId = (int) $this-&gt;getRequest()-&gt;getParam('id');
          $product = $this-&gt;loadProduct($productId);
          if (!$product) {
              return false;
          }
          /** @var \Magento\Framework\View\Result\Layout $resultLayout */
          $resultLayout = $this-&gt;resultFactory-&gt;create(ResultFactory::TYPE_LAYOUT);
          return $resultLayout;
      }
  }
  </code></pre>
  
  <p>My <code>personalised_products_upsellajax.xml</code> - </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd"&gt;
      &lt;container name="root"&gt;
          &lt;block class="MyCompany\MyModule\Block\Product\ProductList\Upsell" name="product.info.personalised.upsell" template="Magento_Catalog::product/list/items.phtml"&gt;
              &lt;arguments&gt;
                  &lt;argument name="type" xsi:type="string"&gt;upsell&lt;/argument&gt;
              &lt;/arguments&gt;
          &lt;/block&gt;
      &lt;/container&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>As you would expect this correctly loads the product upsell block via ajax, pushes the HTML into my container then initialises the <code>upsellProducts</code> widget on the page. My upsell products show as expected but without prices.</p>
  
  <p>I have tried a couple of things to debug the situation but as far as I can see it fails to load the <code>priceRender</code> on line 428 of <code>\Magento\Catalog\Block\Product\AbstractProduct</code> inside the <code>getProductPriceHtml()</code> method. The line <code>$priceRender = $this-&gt;getLayout()-&gt;getBlock('product.price.render.default');</code> always returns <code>false</code> when the block is loaded via AJAX.</p>
  
  <p>This is also the situation when I replace using my block for the default block within the layout (personalised_products_upsellajax.xml) e.g.</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd"&gt;
      &lt;container name="root"&gt;
          &lt;block class="Magento\Catalog\Block\Product\ProductList\Upsell" name="product.info.upsell" template="Magento_Catalog::product/list/items.phtml"&gt;
              &lt;arguments&gt;
                  &lt;argument name="type" xsi:type="string"&gt;upsell&lt;/argument&gt;
              &lt;/arguments&gt;
          &lt;/block&gt;
      &lt;/container&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>I was thinking it might have something to do with the removal of the upsell block first in my layout i.e <code>&lt;referenceBlock name="product.info.upsell" remove="true" /&gt;</code> I decided to comment this line out which results in two upsell blocks appearing, one is the default loaded block and the other is my AJAX block. Same results where the default block show correct information however my AJAX block is still missing prices.</p>
  
  <p>Any help would be greatly appreciated.</p>