Magento 2: Parsing Item information through block
I want to create a phtml file and create a dynamic block with that one to put on CMS pages - Take it as product information blocks where i want to display the product name, the price, the URL - nothing more.
Is it possible to make that with something like the standard magento 2 block variable and link that to a phtml file?
I got something like this in mind:
Magento 2 Block
{{widget type="MagentoCmsBlockWidgetBlock" template="widget/static_block/product-info.phtml" product-id="30"}}
And then get the information within the phtml
file via the used product-id on the block variable but I also got no clue how to approach that.
magento2 product blocks collection variables
add a comment |
I want to create a phtml file and create a dynamic block with that one to put on CMS pages - Take it as product information blocks where i want to display the product name, the price, the URL - nothing more.
Is it possible to make that with something like the standard magento 2 block variable and link that to a phtml file?
I got something like this in mind:
Magento 2 Block
{{widget type="MagentoCmsBlockWidgetBlock" template="widget/static_block/product-info.phtml" product-id="30"}}
And then get the information within the phtml
file via the used product-id on the block variable but I also got no clue how to approach that.
magento2 product blocks collection variables
add a comment |
I want to create a phtml file and create a dynamic block with that one to put on CMS pages - Take it as product information blocks where i want to display the product name, the price, the URL - nothing more.
Is it possible to make that with something like the standard magento 2 block variable and link that to a phtml file?
I got something like this in mind:
Magento 2 Block
{{widget type="MagentoCmsBlockWidgetBlock" template="widget/static_block/product-info.phtml" product-id="30"}}
And then get the information within the phtml
file via the used product-id on the block variable but I also got no clue how to approach that.
magento2 product blocks collection variables
I want to create a phtml file and create a dynamic block with that one to put on CMS pages - Take it as product information blocks where i want to display the product name, the price, the URL - nothing more.
Is it possible to make that with something like the standard magento 2 block variable and link that to a phtml file?
I got something like this in mind:
Magento 2 Block
{{widget type="MagentoCmsBlockWidgetBlock" template="widget/static_block/product-info.phtml" product-id="30"}}
And then get the information within the phtml
file via the used product-id on the block variable but I also got no clue how to approach that.
magento2 product blocks collection variables
magento2 product blocks collection variables
edited 19 mins ago
Teja Bhagavan Kollepara
2,94841847
2,94841847
asked Oct 17 '18 at 16:34
Marcel H.Marcel H.
260624
260624
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
you can do by the following code
{{block class="MagentoFrameworkViewElementTemplate" name="blockname" template="Vendor_Module::test.phtml" product_id="30"}}
in your phtml file
Now you can get the data by calling:
$myVar = $block->getData('product_id'); or $this->getData('product_id');
OR
$myVar = $block->getProductId();
Works! Thank you :) Do you also know how i can get the "incl. xx% VAT" text via this method ? like$product->getProductTax();
?
– Marcel H.
Oct 18 '18 at 8:51
I think you can't get product tax directly in phtml file from cms block/page, but you can get it via phtml file to call function in block check this link
– Hitesh
Oct 18 '18 at 9:18
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f246892%2fmagento-2-parsing-item-information-through-block%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you can do by the following code
{{block class="MagentoFrameworkViewElementTemplate" name="blockname" template="Vendor_Module::test.phtml" product_id="30"}}
in your phtml file
Now you can get the data by calling:
$myVar = $block->getData('product_id'); or $this->getData('product_id');
OR
$myVar = $block->getProductId();
Works! Thank you :) Do you also know how i can get the "incl. xx% VAT" text via this method ? like$product->getProductTax();
?
– Marcel H.
Oct 18 '18 at 8:51
I think you can't get product tax directly in phtml file from cms block/page, but you can get it via phtml file to call function in block check this link
– Hitesh
Oct 18 '18 at 9:18
add a comment |
you can do by the following code
{{block class="MagentoFrameworkViewElementTemplate" name="blockname" template="Vendor_Module::test.phtml" product_id="30"}}
in your phtml file
Now you can get the data by calling:
$myVar = $block->getData('product_id'); or $this->getData('product_id');
OR
$myVar = $block->getProductId();
Works! Thank you :) Do you also know how i can get the "incl. xx% VAT" text via this method ? like$product->getProductTax();
?
– Marcel H.
Oct 18 '18 at 8:51
I think you can't get product tax directly in phtml file from cms block/page, but you can get it via phtml file to call function in block check this link
– Hitesh
Oct 18 '18 at 9:18
add a comment |
you can do by the following code
{{block class="MagentoFrameworkViewElementTemplate" name="blockname" template="Vendor_Module::test.phtml" product_id="30"}}
in your phtml file
Now you can get the data by calling:
$myVar = $block->getData('product_id'); or $this->getData('product_id');
OR
$myVar = $block->getProductId();
you can do by the following code
{{block class="MagentoFrameworkViewElementTemplate" name="blockname" template="Vendor_Module::test.phtml" product_id="30"}}
in your phtml file
Now you can get the data by calling:
$myVar = $block->getData('product_id'); or $this->getData('product_id');
OR
$myVar = $block->getProductId();
answered Oct 18 '18 at 6:26
HiteshHitesh
1,2931423
1,2931423
Works! Thank you :) Do you also know how i can get the "incl. xx% VAT" text via this method ? like$product->getProductTax();
?
– Marcel H.
Oct 18 '18 at 8:51
I think you can't get product tax directly in phtml file from cms block/page, but you can get it via phtml file to call function in block check this link
– Hitesh
Oct 18 '18 at 9:18
add a comment |
Works! Thank you :) Do you also know how i can get the "incl. xx% VAT" text via this method ? like$product->getProductTax();
?
– Marcel H.
Oct 18 '18 at 8:51
I think you can't get product tax directly in phtml file from cms block/page, but you can get it via phtml file to call function in block check this link
– Hitesh
Oct 18 '18 at 9:18
Works! Thank you :) Do you also know how i can get the "incl. xx% VAT" text via this method ? like
$product->getProductTax();
?– Marcel H.
Oct 18 '18 at 8:51
Works! Thank you :) Do you also know how i can get the "incl. xx% VAT" text via this method ? like
$product->getProductTax();
?– Marcel H.
Oct 18 '18 at 8:51
I think you can't get product tax directly in phtml file from cms block/page, but you can get it via phtml file to call function in block check this link
– Hitesh
Oct 18 '18 at 9:18
I think you can't get product tax directly in phtml file from cms block/page, but you can get it via phtml file to call function in block check this link
– Hitesh
Oct 18 '18 at 9:18
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f246892%2fmagento-2-parsing-item-information-through-block%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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