MakkyNZ
MakkyNZ

Reputation: 2255

Magento simple product price not updating after change

I'm using Magento v1.8 and the following code to pull in the price of a simple product

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

The price comes through fine, but when the I update the price of the product in the Magento admin, the updated price value doesn't come through in the code above. The old price is returned.
I've tried clearing Magento cache and reindexing everything using the shell command...

php indexer.php --reindexall

When I var_dump($product) I can see the the new price (£75) is in the protected '_defaultValues' array but the old price (£200) is in the protected '_data' array

Can someone tell me why the price is not updating?

> 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)

Upvotes: 1

Views: 4610

Answers (1)

Thanu
Thanu

Reputation: 2501

Magento product price scope is at website level. From what you are saying, I think you have put the new price at the Default Store level, instead of putting it at web site level. So at website level you still got the old price. Thats why you still see old price for the product.

To fix this either you have to change the website level price to the new price, or select "Use Default" at your website level to get the new price from default store. You can change website levele prices by changing to your website at "Choose Store View" dropdown

P.S: Always remember to run the reindexer after changing price

Upvotes: 2

Related Questions