我想要將自定義文本字段屬性回顯到URL鏈接。如何回顯自定義文本字段屬性,而不是產品網址
我有一個帶有URL鍵「my-page」的CMS頁面,所以我爲一個產品創建了一個名爲「cmspageid」的文本字段,並將URL鍵「my-page」添加到文本字段中。
這裏是整個腳本:
<div class="new-product-content">
<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<h3 class="subtitle new-products"><?php echo $this->__('HOT PRODUCTS') ?></h3>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul>
<?php endif ?>
<li class="thumb<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" ><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(175) ?>" width="175" height="175" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
</a>
<div class="caption">
<h4 class="product-name"> <?php $_productName = $this->helper('core/string')->truncate($this->htmlEscape($_product->getName()),20,'...', $_remainder, true); ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productName ?>">
<?php echo $_productName ?><?php echo $this->__('™'); ?></a></h4>
<?php echo $this->getPriceHtml($_product, true, '-new') ?>
<div class="clearfix"></div>
<div class="desc">
<?php $sdesc = $_product->getShortDescription();
$sdesc = trim($sdesc);
$limit = 180;
if (strlen($sdesc) > $limit) {
$sdesc = substr($sdesc, 0, strrpos(substr($sdesc, 0, $limit), ' '));
} ?>
<?php echo $sdesc."..."; ?>
</div>
<div class="clearfix"></div>
<div class="btn-group">
<button class="btn" type="button" title="<?php echo $this->__('Add to Cart') ?>" onclick="setLocation('<?php echo $this->getProductUrl($_product) ?>')"><?php echo $this->__('Order now...') ?></button>
<button class="btn-link" type="button" title="<?php echo $this->__('More info') ?>" onclick="setLocation('<?php echo $this->getProductUrl($_product) ?>')"><?php echo $this->__('More info?') ?></button>
</li>
<?php if ($i%$_columnCount==0 || $i==count($_products)): ?>
</ul>
<div class="clearfix"></div>
<?php endif ?>
<script type="text/javascript">
$j('.thumb li').last().css('border-right', 'none');
</script>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<?php endforeach; ?>
<?php endif; ?>
<div class="clearfix"></div>
</div>
現在我需要包括cmspageid getProductUrl代替:
<button class="btn-link" type="button" title="<?php echo $this->__('More info') ?>" onclick="setLocation('<?php echo $this->getUrl('')?><?php echo $_product->getCmspageid() ?>')"><?php echo $this->__('More info?') ?></button>
鏈接被點擊所以,當正確的CMS頁面加載。
如果有人能給我們一個手,我會很感激。
非常感謝
也張貼您的HTML代碼。 – bipen
您需要根據產品的自定義屬性調用URL? – Guerra
是的,而不是調用產品的URL,即mysite.com/myproduct.html我想呼應文本字段的值,即mysite.com/mycustomattribute,這是因爲我的CMS頁面的url密鑰將被添加到自定義屬性文本字段,所以CMS頁面將加載...希望是有道理的? – user1704524