Magento 2 Entwicklung: Unterschied zwischen den Versionen

Aus Vosp.info
Wechseln zu:Navigation, Suche
(.phtml get arguments Xml/Cms)
Zeile 5: Zeile 5:
 
<referenceContainer name="content">
 
<referenceContainer name="content">
 
     <block class="Anc\Apname\Block\Blockname" name="ancname" as="ancname" template="Magento_Theme::anc//ancname.phtml" >
 
     <block class="Anc\Apname\Block\Blockname" name="ancname" as="ancname" template="Magento_Theme::anc//ancname.phtml" >
            <arguments>
+
      <arguments>
                <argument name="ancspec" xsi:type="array">
+
            <argument name="ancspec" xsi:type="array">
                        <item name="ancFnc" xsi:type="array">
+
                <item name="ancFnc" xsi:type="array">
                            <item name="product" xsi:type="string">5</item>
+
                      <item name="product" xsi:type="string">5</item>
                        </item>
+
                </item>
                </argument>
+
            </argument>
            </arguments>
+
      </arguments>
        </block>
+
    </block>
 
</referenceContainer>
 
</referenceContainer>
  

Version vom 13. März 2017, 10:14 Uhr

Code Snippets Magento2

.phtml get arguments Xml/Cms

<referenceContainer name="content">
    <block class="Anc\Apname\Block\Blockname" name="ancname" as="ancname" template="Magento_Theme::anc//ancname.phtml" >
       <arguments>
            <argument name="ancspec" xsi:type="array">
                 <item name="ancFnc" xsi:type="array">
                      <item name="product" xsi:type="string">5</item>
                 </item>
            </argument>
       </arguments>
    </block>
</referenceContainer>
$argsFromXml=$block->getData('ancspec') ;

Code Migration Snippets 1.x => 2.x

Bilder

1.x

<img src="<?php echo $this->getSkinUrl('images/product/dir/name.jpg'); ?>" alt="<?php echo $this->__('Name'); ?>"

2.x

<img src="<?php echo $this->getViewFileUrl('images/product/dir/name.jpg'); ?>" alt="<?php echo __('Name'); ?>" />

Helper

1.x

Mage::helper('anchelper')->ancfnc();

2.x

$this->helper('Anc\Appname\Helper\Anchelper');