0

我正在使用 Magento 1.9.2.4 并在我们的自定义 > 模板 > 目录 > 产品 > 视图 > 类型 > 选项 > 可配置的.phtml 文件中有以下代码。

<?php
$_coreHelper = $this->helper('core');
$_weeeHelper = $this->helper('weee');
$_taxHelper = $this->helper('tax');
$_storeId = $_product->getStoreId();
$_store = $_product->getStore();
$_id = $_product->getId();
$_weeeSeparator = '';
$_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
$_minimalPriceValue = $_product->getMinimalPrice();
$_minimalPriceValue = $_store->roundPrice($_store->convertPrice($_minimalPriceValue));
$_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue,$_simplePricesTax);
$_convertedFinalPrice = $_store->roundPrice($_store->convertPrice($_product->getFinalPrice()));
if($this->getProductAttribute('special_price')){     
$_specialPriceStoreLabel = $this->getProductAttribute('special_price')->getStoreLabel(); 
}else{     
$_specialPriceStoreLabel = $_product->getResource()->getAttribute('special_price')->getStoreLabel(); 
}
$_finalPriceInclTax = $_taxHelper->getPrice($_product, $_convertedFinalPrice, true);
?>
<?php if($_product->getTypeId() == "configurable"):
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
foreach($simple_collection as $simple_product){
    echo '<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">';
    echo '<meta itemprop="priceCurrency" content="GBP" />';
    echo $_sku = '<meta itemprop="sku" content="'.$simple_product->getSku().'"/>';

    echo $_price = '<meta itemprop="price" content="'.Mage::helper('core')->currency($_finalPriceInclTax, false, false).'"/>';

    if ($simple_product->isAvailable()):
   echo '<meta content="http://schema.org/InStock" itemprop="availability" />';
   endif;
   if ($_product->getAttributeText('att_condition') == "Yes"):
   echo '<meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition" />';
   else:
    echo '<meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/UsedCondition" />';
    endif;
   echo '<span itemprop="itemOffered" itemscope itemtype="http://schema.org/Thing">';
   echo $_name = '<meta itemprop="name" content="'.$simple_product->getName().'"/>';
   echo '</span>';

    echo '</span>';

}
endif;?>

我们使用色板来显示可配置的项目,并使用一个扩展来在选择色板时切换标题、价格和图像。一切正常,但是由于更改是在 js 中完成的,我无法使用这些细节。所以已经创建了上面的代码,它循环遍历了简单的产品,并为谷歌模式提取了必要的位。伟大的。但是我无法得到正确的价格。目前它正在从可配置持有者那里拉价格,但我希望它从 simple_product 中获取价格。

有任何想法吗?谢谢乔诺

PS这是我第一篇关于stackoverflow的帖子,所以请多多关照!哈哈

4

0 回答 0