I'm investigating loading some product images via knockout templates.
While looking for an example from the core I saw the minicart has this behaviour but right now i don't fully understand how the data is passed to the knockout templates?
Config from
module-checkout/Block/Cart/Sidebar.php
is bound to window.checkout in the minicart template and the initSidebar() function in this block is called when the minicart dropdown is triggered, this window.checkout object includes config for the various Checkout related URL's and the class to render images:
Magento_Catalog/product/image_with_borders
but curiously does not include any products the customer my have in their cart.
The scope for the minicart is minicart_content
, this is defined in a number of XML files found in module-checkout/view/frontend/layout:
checkout_cart_sidebar_item_price_renderers.xml
checkout_cart_sidebar_item_renderers.xml
checkout_cart_sidebar_total_renderers.xml
default.xml
I cannot see anywhere in these layout files where a product model or cart specific data is passed to this minicart_content
scope. So I don't understand how the knockout image template receives its data object which contains alt, height, src & width values for the product. Or for that matter how the minicart receives data for the products the customer has in their cart?
What's the missing link, how is product data passed from a Block to a knockout template?