- Canadian eCommerce (91)
- Canadian eCommerce Benchmark Quarterly Reports (5)
- Canadian eCommerce Monthly Trends (20)
- Careers (5)
- Design & User Experience (32)
- eCommerce (191)
- eCommerce Toronto Meetup (23)
- Email Marketing (1)
- Inbound Marketing (10)
- Infographics (47)
- Integration (1)
- Magento Commerce (90)
- Magento Extensions Updates (11)
- Mobile (11)
- Press Releases (1)
- Project Management (9)
- Ramblings (40)
- Search Engine Marketing (12)
- Search Engine Optimization (11)
- Site Launches (7)
- Social Media (16)
- This Week in eCommerce (14)
- [Infographic Wednesday] – The State of Canadian “Connectedness”
- An Analysis on Canadian Responsive Websites
- [Mini Tutorial] – How to get product attribute with getAttributeRawValue() in Magento
- This Week in eCommerce: May 13 – May 17
- 5 Ways Tablets & Mobile Devices Influence Design Trends
- [Infographic Wednesday] – 10 Ways to Increase Online Sales
- The Basics of Integration between Business Vision Essentials and Magento in C#
- New Site Launch: Books for Christ
- 93% of Canadians are online and searching for product info, so why is there such a disconnect w/ #eCommerce? http://t.co/Wwju9KnjaV
- @mbertulli What's your email? Let's connect offline
- Are Canadian retailers ready for #responsive design websites? #ecommerce http://t.co/K9YX0PMbY8
- Canadians are ahead of the game when it comes to digital. Up to 70% of Canadians use mobile devices. http://t.co/TcGgBUYX8A #eCommerce
- #eCommerce YouTube Finally Makes Some Videos 'Shoppable' via @mashable http://t.co/urYt60O6Ty
- @jschreter Welcome back sir! Excited to have you in our #Toronto office for the next couple of days! #MontrealRepresent
- The State of Canadian Connectedness: Internet Usage, Mobile, Search and Social Media http://t.co/tHYsxLOoG0 #Infographic #eCommerce
- RT @n_forten: Here is a great article on how #Responsive websites are optimal for multi-platform browsing #ecommerce via @demacmedia...
[Mini Tutorial] – Updating Products Within Website Scope

Sometimes in Magento you need to write some code to update products programmatically. This may go hand in hand with wanting to batch update products within a certain store or website scope. Recently we needed to be able to specify which websites should be updated with the ‘price’ attribute. A couple issues stood in our way.
The first being that the scope of all price attributes (price, special price, special from date, special to date, etc.) were not managed in the ‘Manage Attributes’ section in the Magento backend as one would assume. Instead, they can be found in System > Configuration > Catalog > Catalog > Price > Price Scope. You can either choose ‘Global’ (meaning across all websites) or ‘Website’ (for website specific pricing, as we are wanting.) We cannot choose ‘Store’ scope.
We can now use the following code in a function to adjust the price programatically for specific website codes. You’ll also notice below that we set the store to the admin store, something I struggled with. We must set the admin store first, and then set the scope of the specific product later ($product->setStoreId($store->getStoreId());) You may also notice lines like this: $product->setSpecialToDateIsFormated(true);. We need these to pass in a date as a string and tell Magento that it is indeed a date and should be stored that way.
public function updateSpecialPriceByWebsite($price, $specialFromDate, $specialToDate, $sku, $website)
{
try {
$specialFromDate = date('Y-m-d', strtotime($specialFromDate));
$specialToDate = date('Y-m-d', strtotime($specialToDate));
$website = Mage::app()->getWebsite($website);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$store = $website->getDefaultStore();
$product = Mage::getModel('catalog/product');
$productId = $product->getIdBySku($sku);
$product->load($productId);
if ($product && $product->getId()) {
$product->setStoreId($store->getStoreId());
$product->setSpecialFromDate($specialFromDate);
$product->setSpecialFromDateIsFormated(true);
$product->setSpecialToDate($specialToDate);
$product->setSpecialToDateIsFormated(true);
$product->setSpecialPrice(strval($price));
$product->save();
return true;
}
} catch (Exception $e) {
Mage::logException($e);
return false;
}
return true;
}
Hope this helps someone!






