从Magento样品选项中获得简单的价格

时间:2016-07-26 14:52:50

标签: php magento schema price

我正在使用Magento 1.9.2.4并在我们的自定义>中包含以下代码模板>目录>产品>视图>类型>选项> configurable.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中完成的,我无法使用这些细节。所以创建了上面的代码,它循环遍历简单的产品,并为Google架构提取必要的位。大。但是,我无法获得合适的价格。目前它从可配置的持有者那里榨取了价格,但我希望它从simple_product中获取价格。

有什么想法吗? 谢谢Jono

PS这是我的第一篇stackoverflow帖子,所以请你好!洛尔

0 个答案:

没有答案