2013-03-07 59 views
0

我有一個multistore有一些奇怪的問題: 在一個商店$ product-> isAvailable()在一些產品上返回true,但在另一個商店$ product-> isAvailable()總是返回null。Magento 1.7 - 調試isAvailable

在此功能isAvailable()

$this->getTypeInstance(true)->isSalable($this) 

Mage::helper('catalog/product')->getSkipSaleableCheck(); 

都返回NULL。 兩種產品都具有相同的屬性,並且兩個商店都使用有關庫存可用性的一般庫存配置。

升級前我使用v.1.4.0.2,我想isAvailable()/ isSaleable()的邏輯已經改變了一點點。 我沒有得到這兩種產品的差異,這是產品不可用的原因。

//編輯:

一些調試後我發現,該方法

isSalable($product = null) 

由$這個 - 叫> getTypeInstance(真) - > isSalable($本)中isAvailable( )返回0,因爲

$this->getProduct($product)->getData('is_salable') 

是0。這導致哪些屬性負責這個生成is_saleable屬性的問題。

+0

函數不應該是isSaleable()?這是我的。銷售能力=能夠銷售 – dagfr 2013-03-07 17:52:11

+0

函數isSalable()在第294行的Mage/Catalog/Model/Product/Type/Abstract中定義 – s4lfish 2013-03-28 12:59:13

回答

1

你可以嘗試的方案中提到here

基本上你叫isSaleable()或isAvailable()之前它涉及切換到默認存儲。

$originalStore = Mage::app()->getStore(); // save the original store setting 
     Mage::app()->setCurrentStore('default'); //switch to the default store 
     $productsCollection = Mage::getModel('catalog/product')->getCollection(); 
     foreach ($productsCollection as $product) { 
      if (!$product->isSalable()) { 
       // Do what you gotta do 
      } 
     } 
     Mage::app()->setCurrentStore($originalStore->getId()); // switch back to the original 
    }