Magento简单的产品价格在更改后没有更新

时间:2016-08-09 12:32:38

标签: magento

我正在使用Magento v1.8和以下代码来提取简单产品的价格

$prodId  = 27953;
$product = Mage::getModel('catalog/product')->load($prodId);
$price = $product->getPrice();

价格很好,但是当我在Magento管理员中更新产品的价格时,上面的代码中没有更新的价格值。返回旧价格 我已经尝试使用shell命令清除Magento缓存并重新编制索引...

php indexer.php --reindexall

当我var_dump($ product)时,我可以看到新价格(£75)位于受保护的'_defaultValues'数组中 但旧的价格(200英镑)在受保护的'_data'阵列

有人能告诉我为什么价格没有更新?

> object(Mage_Catalog_Model_Product)[54]
>      protected '_defaultValues' => 
>     array (size=28)
>       'name' => string 'Artist Edition - Guy Archard' (length=28)
>       'meta_title' => null
>       'meta_description' => null
>       'image' => string 'no_selection' (length=12)
>       'small_image' => string 'no_selection' (length=12)
>       'thumbnail' => string 'no_selection' (length=12)
>       'url_key' => string 'artist-edition-guy-archard' (length=26)
>       'url_path' => string 'artist-edition-guy-archard.html' (length=31)
>       'page_layout' => null
>       'options_container' => string 'container1' (length=10)
>       'msrp_enabled' => string '2' (length=1)
>       'msrp_display_actual_price_type' => string '4' (length=1)
>       'price' => string '75.0000' (length=7)
>       'special_price' => null
>       'msrp' => null
>       'status' => string '1' (length=1)
>       'visibility' => string '4' (length=1)
>       'tax_class_id' => string '0' (length=1)
>       'description' => null
>       'short_description' => null
>       'meta_keyword' => null
>       'custom_layout_update' => null
>       'special_from_date' => null
>       'special_to_date' => null
>       'news_from_date' => null
>       'news_to_date' => null
>       'custom_design_from' => null
>       'custom_design_to' => null
>      protected '_data' => 
>     array (size=62)
>       'entity_id' => string '27953' (length=5)
>       'entity_type_id' => string '4' (length=1)
>       'attribute_set_id' => string '25' (length=2)
>       'type_id' => string 'simple' (length=6)
>       'sku' => string 'MF-ARTIST-GUY-ARCHARD' (length=21)
>       'has_options' => string '1' (length=1)
>       'required_options' => string '0' (length=1)
>       'created_at' => string '2016-08-08 17:33:06' (length=19)
>       'updated_at' => string '2016-08-08 18:35:40' (length=19)
>       'absolute_price' => string '0' (length=1)
>       'absolute_weight' => string '0' (length=1)
>       'sku_policy' => string '0' (length=1)
>       'name' => string 'Artist Edition - Guy Archard' (length=28)
>       'meta_title' => string 'Guy Archard' (length=11)
>       'meta_description' => string 'Norway' (length=6)
>       'image' => string '/M/F/MF-ARTIST-GUY-ARCHARD_19.jpg' (length=33)
>       'small_image' => string '/M/F/MF-ARTIST-GUY-ARCHARD_19.jpg' (length=33)
>       'thumbnail' => string '/M/F/MF-ARTIST-GUY-ARCHARD_19.jpg' (length=33)
>       'url_key' => string 'artist-edition-guy-archard' (length=26)
>       'url_path' => string 'artist-edition-guy-archard.html' (length=31)
>       'custom_design' => null
>       'page_layout' => null
>       'options_container' => string 'container2' (length=10)
>       'country_of_manufacture' => null
>       'msrp_enabled' => string '2' (length=1)
>       'msrp_display_actual_price_type' => string '4' (length=1)
>       'gift_message_available' => string '0' (length=1)
>       'price' => string '200.0000' (length=8)
>       'special_price' => null
>       'weight' => null
>       'msrp' => null
>       'status' => string '1' (length=1)
>       'is_recurring' => string '0' (length=1)
>       'visibility' => string '4' (length=1)
>       'enable_googlecheckout' => string '1' (length=1)
>       'tax_class_id' => string '0' (length=1)
>       'makeframe_mkyours_shape' => string '1730' (length=4)
>       'makeframe_mkyours_mldstyle' => string '1865' (length=4)
>       'makeframe_mkyours_glazing' => string '1729' (length=4)
>       'makeframe_mkyours_printchoice' => string '1804' (length=4)
>       'makeframe_mkyours_mldcolour' => string '1812' (length=4)
>       'description' => null
>       'short_description' => null
>       'meta_keyword' => null
>       'custom_layout_update' => null
>       'special_from_date' => null
>       'special_to_date' => null
>       'news_from_date' => null
>       'news_to_date' => null
>       'custom_design_from' => null
>       'custom_design_to' => null
>       'image_label' => null
>       'small_image_label' => null
>       'thumbnail_label' => null
>       'group_price' => 
>         array (size=0)
>           empty
>       'group_price_changed' => int 0
>       'media_gallery' => 
>         array (size=2)
>           'images' => 
>             array (size=2)
>               ...
>           'values' => 
>             array (size=0)
>               ...
>       'tier_price' => 
>         array (size=0)
>           empty
>       'tier_price_changed' => int 0
>       'stock_item' => 
>         object(Mage_CatalogInventory_Model_Stock_Item)[296]
>           private '_minSaleQtyCache' => 
>             array (size=0)
>               ...
>           protected '_qtyIncrements' => null
>           protected '_eventPrefix' => string 'cataloginventory_stock_item' (length=27)
>           protected '_eventObject' => string 'item' (length=4)
>           protected '_productInstance' => 
>             &object(Mage_Catalog_Model_Product)[54]
>           protected '_customerGroupId' => null
>           protected '_processIndexEvents' => boolean true
>           protected '_resourceName' => string 'cataloginventory/stock_item' (length=27)
>           protected '_resource' => null
>           protected '_resourceCollectionName' => string 'cataloginventory/stock_item_collection' (length=38)
>           protected '_cacheTag' => boolean false
>           protected '_dataSaveAllowed' => boolean true
>           protected '_isObjectNew' => null
>           protected '_data' => 
>             array (size=33)
>               ...
>           protected '_hasDataChanges' => boolean true
>           protected '_origData' => 
>             array (size=28)
>               ...
>           protected '_idFieldName' => string 'item_id' (length=7)
>           protected '_isDeleted' => boolean false
>           protected '_oldFieldsMap' => 
>             array (size=2)
>               ...
>           protected '_syncFieldsMap' => 
>             array (size=4)
>               ...
>       'is_in_stock' => string '1' (length=1)
>       'is_salable' => string '1' (length=1)

1 个答案:

答案 0 :(得分:2)

Magento产品价格范围在网站级别。根据您的说法,我认为您已将新价格置于默认商店级别,而不是将其置于网站级别。所以在网站级别你仍然有旧的价格。这就是为什么你仍然看到产品的旧价格。

要解决此问题,您必须将网站级价格更改为新价格,或选择"使用默认"在您的网站级别从默认商店获取新价格。您可以通过更改到您的网站来更改网站的价格,并选择商店视图"下拉

P.S:永远记得在更改价格后运行重新索引