我在文件image_with_border.phtml
中有此代码。我希望能够在URL后面添加sku代码。
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php /** @var $block \Magento\Catalog\Block\Product\Image */ ?>
<span class="product-image-container"
style="width:<?= /* @escapeNotVerified */ $block->getWidth() ?>px;">
<span class="product-image-wrapper"
style="padding-bottom: <?= /* @escapeNotVerified */ ($block->getRatio() * 100) ?>%;">
<img class="product-image-photo"
<?= /* @escapeNotVerified */ $block->getCustomAttributes() ?>
src="www.nuovo.it/"<? here would insert Sku code ?>
max-width="<?= /* @escapeNotVerified */ $block->getWidth() ?>"
max-height="<?= /* @escapeNotVerified */ $block->getHeight() ?>"
alt="<?= /* @escapeNotVerified */ $block->stripTags($block->getLabel(), null, true) ?>"/></span>
</span>
首先为您的BASE链接创建一个变量。
$link="https://www.nuovo.it/";
然后获取SKU代码并通过strtolower
函数(通常将所有内容保持在较低水平,但无需执行下一步)是一个好习惯,] >>。我不知道如何您将在此处获取SKU代码,因此例如,可以随意更改strtolower( )
添加的帖子的内部。
$sku=strtolower($_POST['SKUCODE']);
只需将其与
$link
变量连接
$newlink=$link.$sku;
使用
$newlink
中的src
变量>>
src="<?php echo "$newlink" ?>"