Iptrack-Magento
我在Magento中使用Iptrack扩展。基于IP检测,如果适用,将为产品显示以下规范:; 规格-它是产品的属性 如果IP来自英国或美国且语言为英语: 显示所有I-和G-规格 其他IP和语言: 显示所有M和G规格 这就是属性的来源:attributes.phtml: 一个循环Iptrack-Magento,magento,ip,Magento,Ip,我在Magento中使用Iptrack扩展。基于IP检测,如果适用,将为产品显示以下规范:; 规格-它是产品的属性 如果IP来自英国或美国且语言为英语: 显示所有I-和G-规格 其他IP和语言: 显示所有M和G规格 这就是属性的来源:attributes.phtml: 一个循环 也许有人也有同样的问题?谢谢。如果我理解正确,您可以通过以下方式实现您的目标: <?php $_helper = $this->helper('catalog/output'); $_prod
也许有人也有同样的问题?谢谢。如果我理解正确,您可以通过以下方式实现您的目标:
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
function isAllowedAttribute($aData)
{
$bIpCheck = (bool) preg_match('/^[igm]{1}[0-9]{3}$/', $aData['code']);
if (!$bIpCheck) {
return true;
}
if (isIpFromUkOrUsAndLanguageEnglish()) {
return (bool) preg_match('/^[ig]{1}[0-9]{3}$/', $aData['code']);
}
else {
return (bool) preg_match('/^[mg]{1}[0-9]{3}$/', $aData['code']);
}
}
?>
<?php if($_additional = $this->getAdditionalData()): ?>
<h2><?php echo $this->__('Additional Information') ?></h2>
<table class="data-table" id="product-attribute-specs-table">
<col width="25%" />
<col />
<tbody>
<?php foreach ($_additional as $_data): ?>
<?php if (isAllowedAttribute($_data)): ?>
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
<?php endif;?>
我根本不知道您使用的这个IP跟踪扩展,所以我只是使用了一个对不存在的函数isIpFromUkOrUsAndLanguageEnglish的伪调用
您只需使用正确的IP跟踪分机呼叫来替换此呼叫。您需要更加具体。从未听说过I-/G-/M-规格可能太本地化了。I-/G-/M-规格-这是我的产品属性。例如m003-属性代码。如果它是一个属性,那么$collection->addAttributeToFilter通常就是您所需要的。请张贴您的代码建设的产品集合显示。希望我张贴正确的页面;好的,我们不是在谈论集合,而是一个单一的产品。您只告诉我们m003是您的自定义产品属性名称之一。请列出所有的I/G/M属性名称,这样我们可以看到您使用的命名逻辑。如果我将代码替换为此,它将不起作用:甚至是唯一的函数。您发布的attributes.phtml是否已被证明可用?或者这是一个错误的模板?如果attributes.phtml被证明被使用,请在你的帖子中添加一个$\u数据转储。我进行了转储和编辑帖子。我检查,我使用的是准确的属性。phtml然后这应该可以肯定。请将isIpFromUkOrUsAndLanguageEnglish替换为1==1,以强制触发if案例。根据您添加的转储代码=>'i061',输出应包含直径D英寸标签。
array(3) { ["label"]=> string(19) "Diameter D (inches)" ["value"]=> string(7) "2 11/16" ["code"]=> string(4) "i062" } Diameter D (inches)
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
function isAllowedAttribute($aData)
{
$bIpCheck = (bool) preg_match('/^[igm]{1}[0-9]{3}$/', $aData['code']);
if (!$bIpCheck) {
return true;
}
if (isIpFromUkOrUsAndLanguageEnglish()) {
return (bool) preg_match('/^[ig]{1}[0-9]{3}$/', $aData['code']);
}
else {
return (bool) preg_match('/^[mg]{1}[0-9]{3}$/', $aData['code']);
}
}
?>
<?php if($_additional = $this->getAdditionalData()): ?>
<h2><?php echo $this->__('Additional Information') ?></h2>
<table class="data-table" id="product-attribute-specs-table">
<col width="25%" />
<col />
<tbody>
<?php foreach ($_additional as $_data): ?>
<?php if (isAllowedAttribute($_data)): ?>
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
<?php endif;?>