Magento 拡張機能 Firegento German Setup をインストールしたところ、正常に動作します。残念ながら、別の拡張 SCP (Simple Configurable Products) は、現在、望ましくない動作を示しています。SCP が記事用に作成するフィールド「価格から」は、Firegento ドイツ語セットアップのインストール後に消えます。Firegento を再度アンインストールすると、SCP は以前と同じように「価格元」フィールドを表示します。明らかに、SCP フィールドの "Price from" は Firegento によって上書きされます。どちらの拡張機能にも独自の「price.php」があり、競合はこれら 2 つのファイルにあると思います。誰かが解決策を知っていますか? 助けてください、事前に感謝します。マリオ
拡張SCP Simple Configurable Productsのprice.php以下
public function _toHtml() {
$htmlToInsertAfter = '<div class="price-box">';
if ($this->getTemplate() == 'catalog/product/price.phtml') {
$product = $this->getProduct();
if (is_object($product) && $product->isConfigurable()) {
$extraHtml = '<span class="label" id="configurable-price-from-'
. $product->getId()
. $this->getIdSuffix()
. '"><span class="configurable-price-from-label">';
if ($product->getMaxPossibleFinalPrice() != $product->getFinalPrice()) {
$extraHtml .= $this->__('Price From:');
}
$extraHtml .= '</span></span>';
$priceHtml = parent::_toHtml();
#manually insert extra html needed by the extension into the normal price html
return substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
}
}
return parent::_toHtml();
}
そして、ここに Firegento_ 拡張機能の price.php が来ます
*/
public function _toHtml()
{
$html = trim(parent::_toHtml());
if (empty($html) || !Mage::getStoreConfigFlag('catalog/price/display_block_below_price')) {
return $html;
}
if (!in_array($this->getTemplate(), $this->_tierPriceDefaultTemplates)) {
$htmlObject = new Varien_Object();
$htmlObject->setParentHtml($html);
$htmlTemplate = $this->getLayout()->createBlock('core/template')
->setTemplate('germansetup/price_info.phtml')
->setFormattedTaxRate($this->getFormattedTaxRate())
->setIsIncludingTax($this->isIncludingTax())
->setIsIncludingShippingCosts($this->isIncludingShippingCosts())
->setIsShowShippingLink($this->isShowShippingLink())
->setIsShowWeightInfo($this->getIsShowWeightInfo())
->setFormattedWeight($this->getFormattedWeight())
->toHtml();
$htmlObject->setHtml($htmlTemplate);
$this->_addDeliveryTimeHtml($htmlObject);
Mage::dispatchEvent('germansetup_after_product_price',
array(
'html_obj' => $htmlObject,
'block' => $this,
)
);
$html = $htmlObject->getPrefix();
$html .= $htmlObject->getParentHtml();
$html .= $htmlObject->getHtml();
$html .= $htmlObject->getSuffix();
}
return $html;
}
/**
* Add delivery time on category pages only
*
* @param $htmlObject
*/
protected function _addDeliveryTimeHtml($htmlObject)
{
if (!Mage::getStoreConfigFlag('catalog/price/display_delivery_time_on_categories')) {
return;
}
$pathInfo = Mage::app()->getRequest()->getPathInfo();
if (strpos($pathInfo, 'catalog/category/view') !== false
|| strpos($pathInfo, 'catalogsearch/result') !== false) {
if ($this->getProduct()->getDeliveryTime()) {
$html = '<p class="delivery-time">';
$html .= $this->__('Delivery Time') . ': ' . $this->getProduct()->getDeliveryTime();
$html .= '</p>';
$htmlObject->setSuffix($html);
}
}
}
/**
* Read tax rate from current product.
*
* @return string
*/
public function getTaxRate()
{
$taxRateKey = 'tax_rate_'.$this->getProduct()->getId();
if (!$this->getData($taxRateKey)) {
$this->setData($taxRateKey, $this->_loadTaxCalculationRate($this->getProduct()));
}
return $this->getData($taxRateKey);
}
/**
* Retrieves formatted string of tax rate for user output
*
* @return string
*/
public function getFormattedTaxRate()
{
if ($this->getTaxRate() === null
|| $this->getProduct()->getTypeId() == 'bundle'
) {
return '';
}
$locale = Mage::app()->getLocale()->getLocaleCode();
$taxRate = Zend_Locale_Format::toFloat($this->getTaxRate(), array('locale' => $locale));
return $this->__('%s%%', $taxRate);
}
/**
* Returns whether or not the price contains taxes
*
* @return bool
*/
public function isIncludingTax()
{
if (!$this->getData('is_including_tax')) {
$this->setData('is_including_tax', Mage::getStoreConfig('tax/display/type'));
}
return $this->getData('is_including_tax');
}
/**
* Returns whether or not the price contains taxes
*
* @return bool
*/
public function isIncludingShippingCosts()
{
if (!$this->getData('is_including_shipping_costs')) {
$this->setData(
'is_including_shipping_costs',
Mage::getStoreConfig('catalog/price/including_shipping_costs')
);
}
return $this->getData('is_including_shipping_costs');
}
/**
* Returns whether the shipping link needs to be shown
* on the frontend or not.
*
* @return bool
*/
public function isShowShippingLink()
{
$productTypeId = $this->getProduct()->getTypeId();
$ignoreTypeIds = array('virtual', 'downloadable');
if (in_array($productTypeId, $ignoreTypeIds)) {
return false;
}
return true;
}
/**
* Gets tax percents for current product
*
* @param Mage_Catalog_Model_Product $product
* @return string
*/
protected function _loadTaxCalculationRate(Mage_Catalog_Model_Product $product)
{
$taxPercent = $product->getTaxPercent();
if (is_null($taxPercent)) {
$taxClassId = $product->getTaxClassId();
if ($taxClassId) {
$request = Mage::getSingleton('tax/calculation')->getRateRequest(null, null, null, null);
$taxPercent = Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxClassId));
}
}
if ($taxPercent) {
return $taxPercent;
}
return 0;
}
/**
* Check if Shipping by Weight is active
*
* @return bool
*/
public function getIsShowWeightInfo()
{
return Mage::getStoreConfigFlag('catalog/price/display_product_weight');
}
/**
* Get formatted weight incl. unit
*
* @return string
*/
public function getFormattedWeight()
{
return floatval($this->getProduct()->getWeight()) . ' ' . Mage::getStoreConfig('catalog/price/weight_unit');
}
/**
* Translate block sentence
*
* @return string
*/
public function __()
{
$args = func_get_args();
$expr = new Mage_Core_Model_Translate_Expr(array_shift($args), 'Mage_Catalog');
array_unshift($args, $expr);
return Mage::app()->getTranslator()->translate($args);
}
}