久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在產品上調用 isInStock() 方法的 Magento 問題

Magento issue with calling isInStock() method on a product(在產品上調用 isInStock() 方法的 Magento 問題)
本文介紹了在產品上調用 isInStock() 方法的 Magento 問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想檢查一些產品是否有庫存,但無論我做什么,isInStock() 方法總是返回 TRUE.我的產品是沒有關聯產品的可配置產品,在庫存"選項卡下,庫存可用性"設置為缺貨".我究竟做錯了什么?謝謝!

I want to check if some products are in stock but whatever I do the isInStock() method always returns TRUE. My products are configurable products with no associated products and under the "Inventory" tab "Stock Availability" is set to "Out of Stock". What am I doing wrong? Thanks!

推薦答案

Magento 在這一點上有很多歷史,所以最好不要總是相信方法名稱會做看起來很明顯"的事情.現在明顯在幾年前并不明顯.

Magento has a lot of history at this point, so it's a good idea to not always trust that method names will do what "seems obvious". Obvious now wasn't obvious a few years ago.

如果你在 Mage_Catalog_Model_Product 類上查看以下兩個方法

If you look at the following two methods on the Mage_Catalog_Model_Product class

public function isInStock()
{
    return $this->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
}
public function getStatus()
{
    return $this->_getData('status');
}

您可以看到 isInStock 檢查了 status 屬性,該屬性在產品管理員的常規"部分中設置.

You can see that isInStock checks the status attribute, set in the "General" section of the Product admin.

試試這個

$stockItem = $product->getStockItem();
if($stockItem->getIsInStock())
{
    //in stock!
}
else
{
    //not in stock!
}

這篇關于在產品上調用 isInStock() 方法的 Magento 問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 国产精品久久久久久一级毛片 | 日韩在线精品强乱中文字幕 | 色婷婷综合网站 | 91亚洲国产精品 | 欧美综合国产精品久久丁香 | 一区二区三区高清 | 亚洲国产精品成人无久久精品 | 亚洲成人黄色 | 国产日批 | 岛国av免费看 | 精品一区二区三区在线观看国产 | 久久精品亚洲国产奇米99 | 国产精品久久久久久久模特 | 在线只有精品 | 国产高清在线精品 | www四虎com | 国产999精品久久久 午夜天堂精品久久久久 | 欧美成人激情 | 隔壁老王国产在线精品 | 日韩视频 中文字幕 | 视频一区二区在线观看 | 三区四区在线观看 | 青青草亚洲 | 色综合区 | 午夜精品久久久久久久久久久久久 | 成人在线小视频 | 暖暖日本在线视频 | 日韩一级免费大片 | 国产日韩精品一区二区三区 | 天天艹逼网 | 成人免费网站视频 | www亚洲精品 | 欧美黄色一区 | 日本在线视| 亚洲视频一区在线观看 | 色综合久久久 | 极品粉嫩国产48尤物在线播放 | 欧美视频中文字幕 | 91在线视频播放 | 国产精品久久久久久久久久久新郎 | 国产探花在线精品一区二区 |