0

親が同じカテゴリだけ比較したいのですが、

たとえば、ユーザーは nokia mobile と samsung mobile を比較できますが、nokia mobile と靴を比較したい場合、これらの製品を比較することはできません。

ヘルプは大歓迎です

前もって感謝します

4

1 に答える 1

2

app\code\core\Mage\Catalog\controllers\Product\CompareController.php\ で、次のように変更します。

if ($product->getId() /* && !$product->isSuper() */ ) {
$categoryIds = $product->getCategoryIds();
if (is_array($categoryIds) and count($categoryIds) > 1) {
$cat = Mage::getModel('catalog/category')->load($categoryIds[2]);
if(!isset($_SESSION['compare']))
{
$_SESSION['compare']=$cat->getId();
$_SESSION['comparecount']=0;
}
if($cat->getId() == $_SESSION['compare'] /* || $cat->getId() == 13 ||$cat->getId() == 18 ||$cat->getId() == 35*/ ) ///come back here
{
$_SESSION['comparecount']++;
Mage::getSingleton('catalog/product_compare_list')->addProduct($product);
Mage::getSingleton('catalog/session')->addSuccess(
$this->__('The product %s has been added to comparison list.:)', Mage::helper('core')->escapeHtml($product->getName()))
);
Mage::dispatchEvent('catalog_product_compare_add_product', array('product'=>$product));
}else
{
Mage::getSingleton('catalog/session')->addSuccess(
$this->__('The product %s not possible to add in comparison list.:(', Mage::helper('core')->escapeHtml($product->getName()))
);

}
}}

//// Same file in function removeAction() after condition
if($item->getId()) {
$item->delete();

/// add the following lines
$_SESSION['comparecount']--;
if($_SESSION['comparecount']<1) { unset($_SESSION['comparecount']); unset($_SESSION['compare']); }

//// Same file in function clearAction() after try { $items->clear();

//// add the following lines
unset($_SESSION['compare']);

それはすべての男です.比較をお楽しみください...ここは私のブログです。比較をお楽しみください。

于 2014-03-27T06:52:56.093 に答える