Solution:
Install magento dull image uploader / No flash image uploader extension (Here). This will help to import images.
That’s all, go to admin panel in Magento admin panel and upload and import product successfully.
"sku","qty","is_in_stock"
"prod1","100","1"
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
umask(0); $count = 0;
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$file = fopen(MAGENTO . '/var/import/updateStockLevels.csv', 'r');
while (($line = fgetcsv($file)) !== FALSE) {
if ($count == 0) {
foreach ($line as $key=>$value) {
$cols[$value] = $key;
}
}
$count++;
if ($count == 1) continue;
#Convert the lines to cols
if ($count > 0) {
foreach($cols as $col=>$value) {
unset(${$col});
${$col} = $line[$value];
}
}
// Check if SKU exists
$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
if ( $product ) {
$productId = $product->getId();
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
$stockItemId = $stockItem->getId();
$stock = array();
if (!$stockItemId) {
$stockItem->setData('product_id', $product->getId());
$stockItem->setData('stock_id', 1);
} else {
$stock = $stockItem->getData();
}
foreach($cols as $col=>$value) {
$stock[$col] = $line[$value];
}
foreach($stock as $field => $value) {
$stockItem->setData($field, $value?$value:0);
}
$stockItem->save();
unset($stockItem); unset($product);
}
echo "
Stock updated $sku";
}
fclose($file);
You can set your template to 1column like this:page/2columns-right.phtml
or use "<remove name="right"/>"page/1column.phtml
After making changes dont forget to refresh the cache. That's it. You are done.page/2columns-right.phtml
<?php
$_compareUrl = $this->helper('catalog/product_compare')->getAddUrl($_product);
?>
<?php if($_compareUrl) : ?>
<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>
for instance, use this code to remove the sidebar cart from the product view page.
$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
if ($item->getProduct()->getId() == $productId) {
$itemId = $item->getItemId();
$cartHelper->getCart()->removeItem($itemId)->save();
break;
}
}
Note:<?php $categories = $_product->getCategoryIds(); ?>
<?php foreach($categories as $k => $_category_id): ?>
<?php $_category = Mage::getModel('catalog/category')->load($_category_id) ?>
<a href="<?php echo $_category->getUrl() ?>"><?php echo $_category->getName() ?></a>
<?php endforeach; ?> This will load and link all of the categories that the product is found in.
/**
* Number of products to display
* You may change it to your desired value
*/
$productCount = 5;
/**
* Get Store ID
*/
$storeId = Mage::app()->getStore()->getId();
/**
* Get most viewed product collection
*/
$products = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->setStoreId($storeId)
->addStoreFilter($storeId)
->addViewsCount()
->setPageSize($productCount);
Mage::getSingleton('catalog/product_status')
->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')
->addVisibleInCatalogFilterToCollection($products);
print_r($products);
$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->addAttributeToFilter('brand', array('in' => array(11)));
$_productCollection->addAttributeToSelect('*');
$_productCollection->load();