Magento-2: passing arguments in layout xml to block
Arguments are injected in the block __construct
method:
<?php
...
class YourBlock extends Template {
...
public function __construct(
Context $context,
array $data = []
) {
// Here, $data contains an hash with the passed arguments
parent::__construct($context, $data);
}
...
}
...
And according to DataObject
, you should be able to accesss them from your template by using:
$block->getData('mykey');
And as you can understand their meaning depends on the block's logic.
But prices are not passed as arguments, what you need is probably need to add a price block or add a piece of code in your template files. I think XML layout will not help you in this.
You doesn't need to do passing value between layout block. You just keep below line to your view file and getting price same as details page.
$priceBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\ListProduct');
//getting $product object, passed $product object inside function
echo $priceBlock->getProductPrice($product);
You have to display price same as details page and you have to apply some css for special price product to hide text of special price.