-4

我很想知道Magento 如何禁用产品

处理产品状态的代码在哪里,即在 Magento 中启用禁用

请提供我在 Magento 中禁用产品的代码位置?

4

1 回答 1

3

更加努力地搜索您的答案可能会对您有所帮助:

http://www.magentocommerce.com/boards/viewthread/195388/#t243282

Mage::getModel('catalog/product_status')->updateProductStatus($product->getId(), $storeId, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);

此外,您可以(在 linux 上)运行以下 grep 命令

grep -rin -A2 -B2 "updateProductStatus" *

找出可能调用那段代码的实例的位置。

编辑:在 Magento 1.6.2.0 上,您可以在此处找到它。(例如上面的shell命令的结果)

electricjesus@quadsrv64:~/projects/magento/magento/app$ grep -rin -A2 -B2 "updateProductStatus" *
code/core/Mage/Catalog/Model/Product/Flat/Indexer.php-172-     * @return Mage_Catalog_Model_Product_Flat_Indexer
code/core/Mage/Catalog/Model/Product/Flat/Indexer.php-173-     */
code/core/Mage/Catalog/Model/Product/Flat/Indexer.php:174:    public function updateProductStatus($productId, $status, $store = null)
code/core/Mage/Catalog/Model/Product/Flat/Indexer.php-175-    {
code/core/Mage/Catalog/Model/Product/Flat/Indexer.php-176-        if (is_null($store)) {
code/core/Mage/Catalog/Model/Product/Flat/Indexer.php-177-            foreach (Mage::app()->getStores() as $store) {
code/core/Mage/Catalog/Model/Product/Flat/Indexer.php:178:                $this->updateProductStatus($productId, $status, $store->getId());
code/core/Mage/Catalog/Model/Product/Flat/Indexer.php-179-            }
code/core/Mage/Catalog/Model/Product/Flat/Indexer.php-180-            return $this;
--
code/core/Mage/Catalog/Model/Product/Flat/Observer.php-110-        $storeId    = $storeId > 0 ? $storeId : null;
code/core/Mage/Catalog/Model/Product/Flat/Observer.php-111-
code/core/Mage/Catalog/Model/Product/Flat/Observer.php:112:        $this->_getIndexer()->updateProductStatus($productId, $status, $storeId);
code/core/Mage/Catalog/Model/Product/Flat/Observer.php-113-
code/core/Mage/Catalog/Model/Product/Flat/Observer.php-114-        return $this;
--
code/core/Mage/Catalog/Model/Product/Indexer/Flat.php-317-            if (isset($data['catalog_product_flat_status'])) {
code/core/Mage/Catalog/Model/Product/Indexer/Flat.php-318-                $status = $data['catalog_product_flat_status'];
code/core/Mage/Catalog/Model/Product/Indexer/Flat.php:319:                $this->_getIndexer()->updateProductStatus($productIds, $status);
code/core/Mage/Catalog/Model/Product/Indexer/Flat.php-320-            }
code/core/Mage/Catalog/Model/Product/Indexer/Flat.php-321-
--
code/core/Mage/Catalog/Model/Product/Status.php-198-     * @return  Mage_Catalog_Model_Product_Status
code/core/Mage/Catalog/Model/Product/Status.php-199-     */
code/core/Mage/Catalog/Model/Product/Status.php:200:    public function updateProductStatus($productId, $storeId, $value)
code/core/Mage/Catalog/Model/Product/Status.php-201-    {
code/core/Mage/Catalog/Model/Product/Status.php-202-        Mage::getSingleton('catalog/product_action')
--
code/core/Mage/Catalog/Model/Resource/Product/Status.php-106-     * @return Mage_Catalog_Model_Resource_Product_Status
code/core/Mage/Catalog/Model/Resource/Product/Status.php-107-     */
code/core/Mage/Catalog/Model/Resource/Product/Status.php:108:    public function updateProductStatus($productId, $storeId, $value)
code/core/Mage/Catalog/Model/Resource/Product/Status.php-109-    {
code/core/Mage/Catalog/Model/Resource/Product/Status.php-110-        $statusAttributeId  = $this->_getProductAttribute('status')->getId();
于 2012-06-01T09:45:32.897 回答