2013-03-07 47 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 
    }