Magento 2 Entwicklung: Unterschied zwischen den Versionen
Aus Vosp.info
V (Diskussion | Beiträge) (→Code Migration Snippets 1.x => 2.x) |
V (Diskussion | Beiträge) (→Bilder) |
||
Zeile 35: | Zeile 35: | ||
<source lang=php> | <source lang=php> | ||
<img src="<?php echo $this->getSkinUrl('images/product/dir/name.jpg'); ?>" alt="<?php echo $this->__('Name'); ?>" | <img src="<?php echo $this->getSkinUrl('images/product/dir/name.jpg'); ?>" alt="<?php echo $this->__('Name'); ?>" | ||
+ | </source> | ||
+ | |||
+ | <source lang=xml> | ||
+ | {{skin url='images/product/dir/name.jpg'}} | ||
</source> | </source> | ||
==== 2.x ==== | ==== 2.x ==== | ||
Zeile 40: | Zeile 44: | ||
<img src="<?php echo $this->getViewFileUrl('images/product/dir/name.jpg'); ?>" alt="<?php echo __('Name'); ?>" /> | <img src="<?php echo $this->getViewFileUrl('images/product/dir/name.jpg'); ?>" alt="<?php echo __('Name'); ?>" /> | ||
</source> | </source> | ||
+ | |||
+ | <source lang=xml> | ||
+ | {{view url='images/product/dir/name.jpg'}} | ||
+ | </source> | ||
+ | |||
=== Url === | === Url === | ||
==== 1.x ==== | ==== 1.x ==== |
Version vom 18. März 2017, 14:15 Uhr
Inhaltsverzeichnis
Code Snippets Magento2
phtml get arguments Xml/Cms
CMS Page => Design Layout XML
<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>
Phtml File
$argsFromXml=$block->getData('ancspec') ;
Code Migration Snippets 1.x => 2.x
Text Ausgabe
1.x
echo $this->__('Outputtext');
2.x
echo __('Outputtext');
Bilder
1.x
<img src="<?php echo $this->getSkinUrl('images/product/dir/name.jpg'); ?>" alt="<?php echo $this->__('Name'); ?>"
{{skin url='images/product/dir/name.jpg'}}
2.x
<img src="<?php echo $this->getViewFileUrl('images/product/dir/name.jpg'); ?>" alt="<?php echo __('Name'); ?>" />
{{view url='images/product/dir/name.jpg'}}
Url
1.x
<img src="<?php echo Mage::getUrl('produkte'); ?>" ?>"
2.x
<img src="<?php echo $this->getUrl('produkte'); ?>" ?>" />
Helper
1.x
Mage::helper('anchelper')->ancfnc();
2.x
$this->helper('Anc\Appname\Helper\Anchelper');
Currency
1.x
Mage::helper('core')->currency($_product->getPrice(),true,true)
2.x
$this->helper('Magento\Framework\Pricing\Helper\Data')->currency($_product->getPrice(),true,false);