Trying to reproduce the phtml files content from M1.9 to M2.3.

Calling a phtml file via:

{{block class="Magento\Framework\View\Element\Template" name="delivery" template="Magento_Theme::html/Delivery.phtml"}}

What I need to get via an if statement is the following:

  • AttributeSet (Name)
  • AttributeCode (Title & Value)
  • CategoryID

To explain it simply:

Need to check

if the AttributeSet is == 'AttributeSetName' AND if the AttributeCode is == 'attribute_code_value' OR AttributeCode is == 'attribute_code_value' etc. if the CategoryID is == 'CategoryID', then echo specific static block.

What I actually have is the if statement for getting the AttributeSetName.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Framework\Registry')->registry('current_product');
$attributeSet = $objectManager->create('Magento\Eav\Api\AttributeSetRepositoryInterface');
$attributeSetRepository = $attributeSet->get($product->getAttributeSetId());
$attributeSetName = $attributeSetRepository->getAttributeSetName();

//echo $attributeSetName;


if ($attributeSetName == 'XYZ' OR $attributeSetName == 'YZX' OR $attributeSetName == 'ZXY') {

    //    if ($delivery_time == '2 days') {

echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('custom_static_block')->toHtml();



But can not figure it out how to call the custom product attributes and categoryID

The prework on M1 was done years ago and set up everything correctly running. But M2 have different structure.

Hope somebody is able help.

  • Anybody there, who can help in this? – pSolutions Apr 12 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.