Here is the code to fetch the attribute (that should be configurable in magento database) from the CRE Loaded database to magento database
///////////////////////////////CODE/////////////////////////////////
require_once ‘/app/Mage.php’;
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
/////////////////////Create Configurable Attribute From CRE Loaded Database///////////////////////
function createAttribute($code, $label, $attribute_type, $product_type)
{
$_attribute_data = array(
‘attribute_code’ => $code,
‘is_global’ => ’1′,
‘frontend_input’ => $attribute_type, //’boolean’,
‘default_value_text’ => ”,
‘default_value_yesno’ => ’0′,
‘default_value_date’ => ”,
‘default_value_textarea’ => ”,
‘is_unique’ => ’0′,
‘is_required’ => ’0′,
‘apply_to’ => array($product_type), //array(‘grouped’)
‘is_configurable’ => ’1′,
‘is_searchable’ => ’0′,
‘is_visible_in_advanced_search’ => ’0′,
‘is_comparable’ => ’0′,
‘is_used_for_price_rules’ => ’0′,
‘is_wysiwyg_enabled’ => ’0′,
‘is_html_allowed_on_front’ => ’1′,
‘is_visible_on_front’ => ’0′,
‘used_in_product_listing’ => ’0′,
‘used_for_sort_by’ => ’0′,
‘frontend_label’ => $label
);
$model = Mage::getModel(‘catalog/resource_eav_attribute’);
if (!isset($_attribute_data['is_configurable'])) {
$_attribute_data['is_configurable'] = 0;
}
if (!isset($_attribute_data['is_filterable'])) {
$_attribute_data['is_filterable'] = 0;
}
if (!isset($_attribute_data['is_filterable_in_search'])) {
$_attribute_data['is_filterable_in_search'] = 0;
}
if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) {
$_attribute_data['backend_type'] = $model->getBackendTypeByInput($_attribute_data['frontend_input']);
}
$defaultValueField = $model->getDefaultValueByInput($_attribute_data['frontend_input']);
if ($defaultValueField) {
$_attribute_data['default_value'] = $this->getRequest()->getParam($defaultValueField);
}
$model->addData($_attribute_data);
$model->setEntityTypeId(Mage::getModel(‘eav/entity’)->setType(‘catalog_product’)->getTypeId());
$model->setIsUserDefined(1);
try {
$model->save();
} catch (Exception $e) { echo ‘
Sorry, error occured while trying to save the attribute. Error: ‘.$e->getMessage().’
‘; }
}
////////////////your cre loaded database connection/////////////
$conn = mysql_connect(‘localhost’,'root’,”) ;
mysql_select_db(‘shnoop_cre’,$conn);
//////////////////////////////////////////////////////////////
$select_attributes = @mysql_query(“select * from products_options order by products_options_id”);
while($fetch_attribute = @mysql_fetch_object($select_attributes))
{
if($fetch_attribute->options_type==0)
$input_type=’select’;
elseif($fetch_attribute->options_type==1)
$input_type=’text’;
elseif($fetch_attribute->options_type==2)
$input_type=’radio’;
elseif($fetch_attribute->options_type==3)
$input_type=’checkbox’;
elseif($fetch_attribute->options_type==4)
$input_type=’textarea’;
$Attr_label = $fetch_attribute->products_options_name;
$fetch_attribute->products_options_name = str_replace(‘ ‘,”,$fetch_attribute->products_options_name);
$fetch_attribute->products_options_name = str_replace(‘/’,'_’,$fetch_attribute->products_options_name);
$fetch_attribute->products_options_name = strtolower($fetch_attribute->products_options_name);
createAttribute($fetch_attribute->products_options_name,$Attr_label,$input_type, “configurable”);
}
//////////////////////////////////////////////////////////////////////
//////////////////////Fetch Configurable Attribute Options From CRE Loaded Database To Magento Database/////////////////////////////////
////////////////your cre loaded database connection/////////////
$conn = mysql_connect(‘localhost’,'root’,”) ;
mysql_select_db(‘shnoop_cre’,$conn);
//////////////////////////////////////////////////////////////
$select_attributes = @mysql_query(“select * from products_options order by products_options_id”);
while($fetch_attribute = @mysql_fetch_object($select_attributes))
{
$fetch_attribute->products_options_name = str_replace(‘ ‘,”,$fetch_attribute->products_options_name);
$fetch_attribute->products_options_name = str_replace(‘/’,'_’,$fetch_attribute->products_options_name);
$fetch_attribute->products_options_name = strtolower($fetch_attribute->products_options_name);
$_newOptions = Array();
$select_attribut_options = @mysql_query(“select * from products_options_values_to_products_options where products_options_id=’$fetch_attribute->products_options_id’”);
while($fetch_attribut_option=@mysql_fetch_object($select_attribut_options))
{
$fetch_attribut_option_value = @mysql_fetch_object(mysql_query(“select * from products_options_values where products_options_values_id=’$fetch_attribut_option->products_options_values_id’”));
if(!in_array($fetch_attribut_option_value->products_options_values_name,$_newOptions))
array_push($_newOptions,$fetch_attribut_option_value->products_options_values_name);
}
//Array of values that will become the list of colours
$_attribute = Mage::getModel(‘eav/entity_attribute’)->loadByCode(‘catalog_product’, $fetch_attribute->products_options_name); //change ‘primarycolour’ to any attribute
$_oldOptionArr = array(‘value’=>array(), ‘order’=>array(), ‘delete’=>array());
foreach ( $_attribute->getSource()->getAllOptions(true, true) as $option){
$_oldOptionArr['value'][$option['value']] = array($option['label']);
}
$_newOptionArr = array(‘value’=>array(), ‘order’=>array(), ‘delete’=>array());
$i = 0;
foreach ($_newOptions as $_newOption)
{
$i++;
echo $_newOption;
if(!in_array(Array($_newOption), $_oldOptionArr['value']) && $_newOption != ”) //If the option doesn’t exist already in Magento…
{
$_newOptionArr['value']['option_' . $i] = array($_newOption); //Add the option to the new array
}
}
$_attribute->setOption($_newOptionArr);
$_attribute->save();
}
//////////////////////////////////////////////////////////////
Magento online tutorial, Magento tutorial, Magento Programming. Magento script online, Magento Script, Magento step by step tutorial, Magento tutorial for beginners, Magento tutorial for programmer.
Tuesday, June 25, 2013
Magento: How to change order status programmatically?
Here, I will show you, how you can change your order status programmatically (with PHP coding).
First, you need to load your order.
If you have order id, you can load order in the following way:-
$orderId = YOUR_ORDER_ID;
$order = Mage::getModel(‘sales/order’)
->load($orderId);
If you have order increment id, you can load order in the following way:-
$orderIncrementId = YOUR_ORDER_INCREMENT_ID;
$order = Mage::getModel(‘sales/order’)
->loadByIncrementId($orderIncrementId);
Now, here is the code to change order status:-
/**
* change order status to ‘Completed’
*/
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();
Similarly, you can change the order status to pending, processing, canceled, closed, holded, etc.
/**
* change order status to ‘Pending’
*/
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();
/**
* change order status to ‘Pending Paypal’
*/
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
/**
* change order status to ‘Processing’
*/
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
/**
* change order status to ‘Completed’
*/
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();
/**
* change order status to ‘Closed’
*/
$order->setState(Mage_Sales_Model_Order::STATE_CLOSED, true)->save();
/**
* change order status to ‘Canceled’
*/
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
/**
* change order status to ‘Holded’
*/
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true)->save();
You can also cancel an order in the following way:-
if($order->canCancel()) {
$order->cancel()->save();
}
Hold an order:-
if($order->canHold()) {
$order->hold()->save();
}
Unhold an order:-
if($order->canUnhold()) {
$order->unhold()->save();
}
First, you need to load your order.
If you have order id, you can load order in the following way:-
$orderId = YOUR_ORDER_ID;
$order = Mage::getModel(‘sales/order’)
->load($orderId);
If you have order increment id, you can load order in the following way:-
$orderIncrementId = YOUR_ORDER_INCREMENT_ID;
$order = Mage::getModel(‘sales/order’)
->loadByIncrementId($orderIncrementId);
Now, here is the code to change order status:-
/**
* change order status to ‘Completed’
*/
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();
Similarly, you can change the order status to pending, processing, canceled, closed, holded, etc.
/**
* change order status to ‘Pending’
*/
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();
/**
* change order status to ‘Pending Paypal’
*/
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
/**
* change order status to ‘Processing’
*/
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
/**
* change order status to ‘Completed’
*/
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();
/**
* change order status to ‘Closed’
*/
$order->setState(Mage_Sales_Model_Order::STATE_CLOSED, true)->save();
/**
* change order status to ‘Canceled’
*/
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
/**
* change order status to ‘Holded’
*/
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true)->save();
You can also cancel an order in the following way:-
if($order->canCancel()) {
$order->cancel()->save();
}
Hold an order:-
if($order->canHold()) {
$order->hold()->save();
}
Unhold an order:-
if($order->canUnhold()) {
$order->unhold()->save();
}
How to import CRE Loaded Categories to Magento Database
Transferring one opensource database to other is a common headache.Recently i faced this problem when i need to move the CRE Loaded database to Magento Database.
Here i am giving the code by that you can load the CRE Loaded categories to Magento Database.
//define(‘MAGENTO’, realpath(dirname(__FILE__)));
require_once ‘/app/Mage.php’;
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$count = 0;
/////Cre Loaded Data Base Connection////////////
$conn = mysql_connect(‘localhost’,'root’,”) ;
mysql_select_db(‘shnoop_cre’,$conn);
//////////////////////////////////
$select_categories = @mysql_query(“select * from categories where categories_id=1 or parent_id=1 order by parent_id,categories_id”);
while($fetch_category = @mysql_fetch_object($select_categories))
{
/////Cre Loaded Data Base Connection////////////
$conn = mysql_connect(‘localhost’,'root’,”) ;
mysql_select_db(‘shnoop_cre’,$conn);
////////////////////////////////
$fetch_category_description = @mysql_fetch_object(mysql_query(“select * from categories_description where categories_id=”.$fetch_category->categories_id));
$uri_key = createPageName($fetch_category_description->categories_name);
$data['general']['path'] = ”;
$data['general']['name'] = $fetch_category_description->categories_name;
$data['general']['meta_title'] = “”;
$data['general']['meta_description'] = “”;
$data['general']['is_active'] = 1;
$data['general']['url_key'] = $uri_key;
$data['general']['display_mode'] = “PRODUCTS”;
$data['general']['is_anchor'] = 0;
if($fetch_category->parent_id==0)
$data['category']['parent'] = 4;//$line[0]; // 3 top level
else
$data['category']['parent'] = creLoadedCategoryName($fetch_category->parent_id);
$storeId = 0;
createCategory($data,$storeId);
sleep(0.5);
unset($data);
//}
//}
}
function createCategory($data,$storeId) {
echo “Starting {$data['general']['name']} [{$data['category']['parent']}] …”;
$category = Mage::getModel(‘catalog/category’);
$category->setStoreId($storeId);
# Fix must be applied to run script
#http://www.magentocommerce.com/boards/appserv/main.php/viewreply/157328/
if (is_array($data)) {
$category->addData($data['general']);
if (!$category->getId()) {
$parentId = $data['category']['parent'];
if (!$parentId) {
if ($storeId) {
$parentId = Mage::app()->getStore($storeId)->getRootCategoryId();
}
else {
$parentId = Mage_Catalog_Model_Category::TREE_ROOT_ID;
}
}
if(!is_int($parentId))
$parentId = getMagentoCateogryParentId($parentId);
$parentCategory = Mage::getModel(‘catalog/category’)->load($parentId);
$category->setPath($parentCategory->getPath());
}
/**
* Check “Use Default Value” checkboxes values
*/
if ($useDefaults = $data['use_default']) {
foreach ($useDefaults as $attributeCode) {
$category->setData($attributeCode, null);
}
}
$category->setAttributeSetId($category->getDefaultAttributeSetId());
if (isset($data['category_products']) &&
!$category->getProductsReadonly()) {
$products = array();
parse_str($data['category_products'], $products);
$category->setPostedProducts($products);
}
try {
$category->setIsActive(true);
$category->save();
echo “Suceeded
“;
}
catch (Exception $e){
echo “Failed
“;
}
}
}
function createPageName($Title)
{
$Title = str_split(strtolower($Title));
$allowableArr = array(’0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’a',’b',’c',’d',’e',’f',’g',’h',’i',’j',’k',’l',’m',’n',’o',’p',’q',’r',’s',’t',’u',’v',’w',’x',’y',’z',’-',’ ‘);
$pagename = ”;
for($ii=0;$iicategories_name;
}
function getMagentoCateogryParentId($parname)
{
/////Magento Data Base Connection////////////
$conn2 = mysql_connect(‘localhost’,'root’,”) ;
mysql_select_db(‘mage_maint_151′,$conn2);
//////////////////////////////////
$tableName = Mage::getSingleton(‘core/resource’)->getTableName(‘catalog_category_entity_varchar’);
$fetch_mage_category_details = @mysql_fetch_object(mysql_query(“select * from $tableName where value=’”.addslashes($parname).”‘”));
mysql_close($conn2);
return $fetch_mage_category_details->entity_id;
}
THANKS
Here i am giving the code by that you can load the CRE Loaded categories to Magento Database.
//define(‘MAGENTO’, realpath(dirname(__FILE__)));
require_once ‘/app/Mage.php’;
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$count = 0;
/////Cre Loaded Data Base Connection////////////
$conn = mysql_connect(‘localhost’,'root’,”) ;
mysql_select_db(‘shnoop_cre’,$conn);
//////////////////////////////////
$select_categories = @mysql_query(“select * from categories where categories_id=1 or parent_id=1 order by parent_id,categories_id”);
while($fetch_category = @mysql_fetch_object($select_categories))
{
/////Cre Loaded Data Base Connection////////////
$conn = mysql_connect(‘localhost’,'root’,”) ;
mysql_select_db(‘shnoop_cre’,$conn);
////////////////////////////////
$fetch_category_description = @mysql_fetch_object(mysql_query(“select * from categories_description where categories_id=”.$fetch_category->categories_id));
$uri_key = createPageName($fetch_category_description->categories_name);
$data['general']['path'] = ”;
$data['general']['name'] = $fetch_category_description->categories_name;
$data['general']['meta_title'] = “”;
$data['general']['meta_description'] = “”;
$data['general']['is_active'] = 1;
$data['general']['url_key'] = $uri_key;
$data['general']['display_mode'] = “PRODUCTS”;
$data['general']['is_anchor'] = 0;
if($fetch_category->parent_id==0)
$data['category']['parent'] = 4;//$line[0]; // 3 top level
else
$data['category']['parent'] = creLoadedCategoryName($fetch_category->parent_id);
$storeId = 0;
createCategory($data,$storeId);
sleep(0.5);
unset($data);
//}
//}
}
function createCategory($data,$storeId) {
echo “Starting {$data['general']['name']} [{$data['category']['parent']}] …”;
$category = Mage::getModel(‘catalog/category’);
$category->setStoreId($storeId);
# Fix must be applied to run script
#http://www.magentocommerce.com/boards/appserv/main.php/viewreply/157328/
if (is_array($data)) {
$category->addData($data['general']);
if (!$category->getId()) {
$parentId = $data['category']['parent'];
if (!$parentId) {
if ($storeId) {
$parentId = Mage::app()->getStore($storeId)->getRootCategoryId();
}
else {
$parentId = Mage_Catalog_Model_Category::TREE_ROOT_ID;
}
}
if(!is_int($parentId))
$parentId = getMagentoCateogryParentId($parentId);
$parentCategory = Mage::getModel(‘catalog/category’)->load($parentId);
$category->setPath($parentCategory->getPath());
}
/**
* Check “Use Default Value” checkboxes values
*/
if ($useDefaults = $data['use_default']) {
foreach ($useDefaults as $attributeCode) {
$category->setData($attributeCode, null);
}
}
$category->setAttributeSetId($category->getDefaultAttributeSetId());
if (isset($data['category_products']) &&
!$category->getProductsReadonly()) {
$products = array();
parse_str($data['category_products'], $products);
$category->setPostedProducts($products);
}
try {
$category->setIsActive(true);
$category->save();
echo “Suceeded
“;
}
catch (Exception $e){
echo “Failed
“;
}
}
}
function createPageName($Title)
{
$Title = str_split(strtolower($Title));
$allowableArr = array(’0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’a',’b',’c',’d',’e',’f',’g',’h',’i',’j',’k',’l',’m',’n',’o',’p',’q',’r',’s',’t',’u',’v',’w',’x',’y',’z',’-',’ ‘);
$pagename = ”;
for($ii=0;$iicategories_name;
}
function getMagentoCateogryParentId($parname)
{
/////Magento Data Base Connection////////////
$conn2 = mysql_connect(‘localhost’,'root’,”) ;
mysql_select_db(‘mage_maint_151′,$conn2);
//////////////////////////////////
$tableName = Mage::getSingleton(‘core/resource’)->getTableName(‘catalog_category_entity_varchar’);
$fetch_mage_category_details = @mysql_fetch_object(mysql_query(“select * from $tableName where value=’”.addslashes($parname).”‘”));
mysql_close($conn2);
return $fetch_mage_category_details->entity_id;
}
THANKS
List magento categories and subcategories in different way.
Display Top Level Categories Only
<?php $_helper = Mage::helper(‘catalog/category’) ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_category) ?>”>
<?php echo $_category->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Display Top Level Categories and ALL Subcategories
<?php $_helper = Mage::helper(‘catalog/category’) ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry(‘current_category’) ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_category) ?>”>
<?php echo $_category->getName() ?>
</a>
<?php $_category = Mage::getModel(‘catalog/category’)->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_subcategory) ?>”>
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Display Top Level Categories and Current Categories SubCategories
<?php $_helper = Mage::helper(‘catalog/category’) ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry(‘current_category’) ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_category) ?>”>
<?php echo $_category->getName() ?>
</a>
<?php if ($currentCategory && $currentCategory->getId() == $_category->getId()): ?>
<?php $_category = Mage::getModel(‘catalog/category’)->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_subcategory) ?>”>
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php $_helper = Mage::helper(‘catalog/category’) ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_category) ?>”>
<?php echo $_category->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Display Top Level Categories and ALL Subcategories
<?php $_helper = Mage::helper(‘catalog/category’) ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry(‘current_category’) ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_category) ?>”>
<?php echo $_category->getName() ?>
</a>
<?php $_category = Mage::getModel(‘catalog/category’)->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_subcategory) ?>”>
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Display Top Level Categories and Current Categories SubCategories
<?php $_helper = Mage::helper(‘catalog/category’) ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry(‘current_category’) ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_category) ?>”>
<?php echo $_category->getName() ?>
</a>
<?php if ($currentCategory && $currentCategory->getId() == $_category->getId()): ?>
<?php $_category = Mage::getModel(‘catalog/category’)->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href=”<?php echo $_helper->getCategoryUrl($_subcategory) ?>”>
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Get original image url/path in magento
$productId
=
'SOME_PRODUCT_ID'
;
$product
= Mage::getModel(
'catalog/product'
)->load(
$productId
);
$productMediaConfig
= Mage::getModel(
'catalog/product_media_config'
);
$baseImageUrl
=
$productMediaConfig
->getMediaUrl(
$product
->getImage());
$smallImageUrl
=
$productMediaConfig
->getMediaUrl(
$product
->getSmallImage());
$thumbnailUrl
=
$productMediaConfig
->getMediaUrl(
$product
->getThumbnail());
Get all attributes from an attribute set in magento.
$entityTypeId = Mage::getModel(‘eav/entity’)
->setType(‘catalog_product’)
->getTypeId();
$attributeSetName = ‘Default’; //Edit with your required Attribute Set Name
$attributeSetId = Mage::getModel(‘eav/entity_attribute_set’)
->getCollection()
->setEntityTypeFilter($entityTypeId)
->addFieldToFilter(‘attribute_set_name’, $attributeSetName)
->getFirstItem()
->getAttributeSetId();
$attributesInfo = Mage::getResourceModel(‘eav/entity_attribute_collection’)
->setEntityTypeFilter($attributeSetId) //4 = product entities
->addSetInfo()
->getData();
foreach($attributesInfo as $attribute):
$attributeObj = Mage::getModel(‘eav/entity_attribute’)->load($attribute['attribute_id']);
echo $attribute['frontend_input'];echo ‘<br/>’;
echo ‘label = ‘.$attributeObj->getFrontendLabel().’<br/>’;
echo ‘code = ‘.$attributeObj->getAttributeCode().’<br/><br/>’;
endforeach;
->setType(‘catalog_product’)
->getTypeId();
$attributeSetName = ‘Default’; //Edit with your required Attribute Set Name
$attributeSetId = Mage::getModel(‘eav/entity_attribute_set’)
->getCollection()
->setEntityTypeFilter($entityTypeId)
->addFieldToFilter(‘attribute_set_name’, $attributeSetName)
->getFirstItem()
->getAttributeSetId();
$attributesInfo = Mage::getResourceModel(‘eav/entity_attribute_collection’)
->setEntityTypeFilter($attributeSetId) //4 = product entities
->addSetInfo()
->getData();
foreach($attributesInfo as $attribute):
$attributeObj = Mage::getModel(‘eav/entity_attribute’)->load($attribute['attribute_id']);
echo $attribute['frontend_input'];echo ‘<br/>’;
echo ‘label = ‘.$attributeObj->getFrontendLabel().’<br/>’;
echo ‘code = ‘.$attributeObj->getAttributeCode().’<br/><br/>’;
endforeach;
how to enable error printing in magento?
here is the process to enable the error printing in magento
1. go to magentoRoot/errors folder and make the copy of local.xml.sample
2. then rename the local.xml.sample to local.xml
Now you can see the erros thrown and can easily debug the system
1. go to magentoRoot/errors folder and make the copy of local.xml.sample
2. then rename the local.xml.sample to local.xml
Now you can see the erros thrown and can easily debug the system
Create custom event in magento.
Use below 2 magneto event to dispatch event in magento
<controller_action_predispatch>
<observers>
<pioc_backoffice_shipping_observer>
<class>PIOC_Backoffice_Model_Shipping_Observer</class>
<method>hookToControllerActionPreDispatch</method>
</pioc_backoffice_shipping_observer>
</observers>
</controller_action_predispatch>
<controller_action_postdispatch>
<observers>
<pioc_backoffice_shipping_observer>
<class>PIOC_Backoffice_Model_Shipping_Observer</class>
<method>hookToControllerActionPostDispatch</method>
</pioc_backoffice_shipping_observer>
</observers>
</controller_action_postdispatch>
The below are 2 custom event that we have dispathced at particular point of execution
<pioc_backoffice_shipping_save_before>
<observers>
<pioc_backoffice_shipping_observer>
<type>singleton</type>
<class>PIOC_Backoffice_Model_Shipping_Observer</class>
<method>pioc_shipping_save_before</method>
</pioc_backoffice_shipping_observer>
</observers>
</pioc_backoffice_shipping_save_before>
<pioc_backoffice_shipping_save_after>
<observers>
<pioc_backoffice_shipping_observer>
<type>singleton</type>
<class>PIOC_Backoffice_Model_Shipping_Observer</class>
<method>pioc_shipping_save_after</method>
</pioc_backoffice_shipping_observer>
</observers>
</pioc_backoffice_shipping_save_after>
———Function in observer class to dispatch events——————–
public function hookToControllerActionPreDispatch($observer)
{
//we compare action name to see if that’s action for which we want to add our own event
if($observer->getEvent()->getControllerAction()->getFullActionName() == ‘canvassizecat_adminhtml_myform_post’)
{
//We are dispatching our own event before action ADD is run and sending parameters we need
Mage::dispatchEvent(“pioc_backoffice_shipping_save_before”, array(‘request’ => $observer->getControllerAction()->getRequest()));
}
}
public function hookToControllerActionPostDispatch($observer)
{
if($observer->getEvent()->getControllerAction()->getFullActionName() == ‘canvassizecat_adminhtml_myform_post’)
{
//We are dispatching our own event before action ADD is run and sending parameters we need
Mage::dispatchEvent(“pioc_backoffice_shipping_save_after”, array(‘request’ => $observer->getControllerAction()->getRequest()));
}
}
<controller_action_predispatch>
<observers>
<pioc_backoffice_shipping_observer>
<class>PIOC_Backoffice_Model_Shipping_Observer</class>
<method>hookToControllerActionPreDispatch</method>
</pioc_backoffice_shipping_observer>
</observers>
</controller_action_predispatch>
<controller_action_postdispatch>
<observers>
<pioc_backoffice_shipping_observer>
<class>PIOC_Backoffice_Model_Shipping_Observer</class>
<method>hookToControllerActionPostDispatch</method>
</pioc_backoffice_shipping_observer>
</observers>
</controller_action_postdispatch>
The below are 2 custom event that we have dispathced at particular point of execution
<pioc_backoffice_shipping_save_before>
<observers>
<pioc_backoffice_shipping_observer>
<type>singleton</type>
<class>PIOC_Backoffice_Model_Shipping_Observer</class>
<method>pioc_shipping_save_before</method>
</pioc_backoffice_shipping_observer>
</observers>
</pioc_backoffice_shipping_save_before>
<pioc_backoffice_shipping_save_after>
<observers>
<pioc_backoffice_shipping_observer>
<type>singleton</type>
<class>PIOC_Backoffice_Model_Shipping_Observer</class>
<method>pioc_shipping_save_after</method>
</pioc_backoffice_shipping_observer>
</observers>
</pioc_backoffice_shipping_save_after>
———Function in observer class to dispatch events——————–
public function hookToControllerActionPreDispatch($observer)
{
//we compare action name to see if that’s action for which we want to add our own event
if($observer->getEvent()->getControllerAction()->getFullActionName() == ‘canvassizecat_adminhtml_myform_post’)
{
//We are dispatching our own event before action ADD is run and sending parameters we need
Mage::dispatchEvent(“pioc_backoffice_shipping_save_before”, array(‘request’ => $observer->getControllerAction()->getRequest()));
}
}
public function hookToControllerActionPostDispatch($observer)
{
if($observer->getEvent()->getControllerAction()->getFullActionName() == ‘canvassizecat_adminhtml_myform_post’)
{
//We are dispatching our own event before action ADD is run and sending parameters we need
Mage::dispatchEvent(“pioc_backoffice_shipping_save_after”, array(‘request’ => $observer->getControllerAction()->getRequest()));
}
}
Convert Magento Database to Innodb
ALTER TABLE `admin_assert` ENGINE=InnoDB;
ALTER TABLE `admin_role` ENGINE=InnoDB;
ALTER TABLE `admin_rule` ENGINE=InnoDB;
ALTER TABLE `admin_user` ENGINE=InnoDB;
ALTER TABLE `adminnotification_inbox` ENGINE=InnoDB;
ALTER TABLE `api_assert` ENGINE=InnoDB;
ALTER TABLE `api_role` ENGINE=InnoDB;
ALTER TABLE `api_rule` ENGINE=InnoDB;
ALTER TABLE `api_user` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_int` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_text` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `catalog_category_product` ENGINE=InnoDB;
ALTER TABLE `catalog_category_product_index` ENGINE=InnoDB;
ALTER TABLE `catalog_compare_item` ENGINE=InnoDB;
ALTER TABLE `catalog_product_bundle_option` ENGINE=InnoDB;
ALTER TABLE `catalog_product_bundle_option_value` ENGINE=InnoDB;
ALTER TABLE `catalog_product_bundle_selection` ENGINE=InnoDB;
ALTER TABLE `catalog_product_enabled_index` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_gallery` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_int` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_media_gallery` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_media_gallery_value` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_text` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_tier_price` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_attribute` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_attribute_decimal` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_attribute_int` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_attribute_varchar` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_type` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_price` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_title` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_type_price` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_type_title` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_type_value` ENGINE=InnoDB;
ALTER TABLE `catalog_product_super_attribute` ENGINE=InnoDB;
ALTER TABLE `catalog_product_super_attribute_label` ENGINE=InnoDB;
ALTER TABLE `catalog_product_super_attribute_pricing` ENGINE=InnoDB;
ALTER TABLE `catalog_product_super_link` ENGINE=InnoDB;
ALTER TABLE `catalog_product_website` ENGINE=InnoDB;
ALTER TABLE `catalogindex_aggregation` ENGINE=InnoDB;
ALTER TABLE `catalogindex_aggregation_tag` ENGINE=InnoDB;
ALTER TABLE `catalogindex_aggregation_to_tag` ENGINE=InnoDB;
ALTER TABLE `catalogindex_eav` ENGINE=InnoDB;
ALTER TABLE `catalogindex_minimal_price` ENGINE=InnoDB;
ALTER TABLE `catalogindex_price` ENGINE=InnoDB;
ALTER TABLE `cataloginventory_stock` ENGINE=InnoDB;
ALTER TABLE `cataloginventory_stock_item` ENGINE=InnoDB;
ALTER TABLE `catalogrule` ENGINE=InnoDB;
ALTER TABLE `catalogrule_affected_product` ENGINE=InnoDB;
ALTER TABLE `catalogrule_product` ENGINE=InnoDB;
ALTER TABLE `catalogrule_product_price` ENGINE=InnoDB;
ALTER TABLE `catalogsearch_fulltext` ENGINE=MyISAM;
ALTER TABLE `catalogsearch_query` ENGINE=InnoDB;
ALTER TABLE `catalogsearch_result` ENGINE=InnoDB;
ALTER TABLE `checkout_agreement` ENGINE=InnoDB;
ALTER TABLE `checkout_agreement_store` ENGINE=InnoDB;
ALTER TABLE `cms_block` ENGINE=InnoDB;
ALTER TABLE `cms_block_store` ENGINE=InnoDB;
ALTER TABLE `cms_page` ENGINE=InnoDB;
ALTER TABLE `cms_page_store` ENGINE=InnoDB;
ALTER TABLE `core_config_data` ENGINE=InnoDB;
ALTER TABLE `core_email_template` ENGINE=InnoDB;
ALTER TABLE `core_flag` ENGINE=InnoDB;
ALTER TABLE `core_layout_link` ENGINE=InnoDB;
ALTER TABLE `core_layout_update` ENGINE=InnoDB;
ALTER TABLE `core_resource` ENGINE=InnoDB;
ALTER TABLE `core_session` ENGINE=InnoDB;
ALTER TABLE `core_store` ENGINE=InnoDB;
ALTER TABLE `core_store_group` ENGINE=InnoDB;
ALTER TABLE `core_translate` ENGINE=InnoDB;
ALTER TABLE `core_url_rewrite` ENGINE=InnoDB;
ALTER TABLE `core_website` ENGINE=InnoDB;
ALTER TABLE `cron_schedule` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_int` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_text` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `customer_entity` ENGINE=InnoDB;
ALTER TABLE `customer_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `customer_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `customer_entity_int` ENGINE=InnoDB;
ALTER TABLE `customer_entity_text` ENGINE=InnoDB;
ALTER TABLE `customer_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `customer_group` ENGINE=InnoDB;
ALTER TABLE `dataflow_batch` ENGINE=InnoDB;
ALTER TABLE `dataflow_batch_export` ENGINE=InnoDB;
ALTER TABLE `dataflow_batch_import` ENGINE=InnoDB;
ALTER TABLE `dataflow_import_data` ENGINE=InnoDB;
ALTER TABLE `dataflow_profile` ENGINE=InnoDB;
ALTER TABLE `dataflow_profile_history` ENGINE=InnoDB;
ALTER TABLE `dataflow_session` ENGINE=InnoDB;
ALTER TABLE `design_change` ENGINE=InnoDB;
ALTER TABLE `directory_country` ENGINE=InnoDB;
ALTER TABLE `directory_country_format` ENGINE=InnoDB;
ALTER TABLE `directory_country_region` ENGINE=InnoDB;
ALTER TABLE `directory_country_region_name` ENGINE=InnoDB;
ALTER TABLE `directory_currency_rate` ENGINE=InnoDB;
ALTER TABLE `downloadable_link` ENGINE=InnoDB;
ALTER TABLE `downloadable_link_price` ENGINE=InnoDB;
ALTER TABLE `downloadable_link_purchased` ENGINE=InnoDB;
ALTER TABLE `downloadable_link_purchased_item` ENGINE=InnoDB;
ALTER TABLE `downloadable_link_title` ENGINE=InnoDB;
ALTER TABLE `downloadable_sample` ENGINE=InnoDB;
ALTER TABLE `downloadable_sample_title` ENGINE=InnoDB;
ALTER TABLE `eav_attribute` ENGINE=InnoDB;
ALTER TABLE `eav_attribute_group` ENGINE=InnoDB;
ALTER TABLE `eav_attribute_option` ENGINE=InnoDB;
ALTER TABLE `eav_attribute_option_value` ENGINE=InnoDB;
ALTER TABLE `eav_attribute_set` ENGINE=InnoDB;
ALTER TABLE `eav_entity` ENGINE=InnoDB;
ALTER TABLE `eav_entity_attribute` ENGINE=InnoDB;
ALTER TABLE `eav_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `eav_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `eav_entity_int` ENGINE=InnoDB;
ALTER TABLE `eav_entity_store` ENGINE=InnoDB;
ALTER TABLE `eav_entity_text` ENGINE=InnoDB;
ALTER TABLE `eav_entity_type` ENGINE=InnoDB;
ALTER TABLE `eav_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `gift_message` ENGINE=InnoDB;
ALTER TABLE `googlebase_attributes` ENGINE=InnoDB;
ALTER TABLE `googlebase_items` ENGINE=InnoDB;
ALTER TABLE `googlebase_types` ENGINE=InnoDB;
ALTER TABLE `googlecheckout_api_debug` ENGINE=InnoDB;
ALTER TABLE `googleoptimizer_code` ENGINE=InnoDB;
ALTER TABLE `log_customer` ENGINE=MyISAM;
ALTER TABLE `log_quote` ENGINE=MyISAM;
ALTER TABLE `log_summary` ENGINE=MyISAM;
ALTER TABLE `log_summary_type` ENGINE=MyISAM;
ALTER TABLE `log_url` ENGINE=MyISAM;
ALTER TABLE `log_url_info` ENGINE=MyISAM;
ALTER TABLE `log_visitor` ENGINE=MyISAM;
ALTER TABLE `log_visitor_info` ENGINE=MyISAM;
ALTER TABLE `newsletter_problem` ENGINE=InnoDB;
ALTER TABLE `newsletter_queue` ENGINE=InnoDB;
ALTER TABLE `newsletter_queue_link` ENGINE=InnoDB;
ALTER TABLE `newsletter_queue_store_link` ENGINE=InnoDB;
ALTER TABLE `newsletter_subscriber` ENGINE=InnoDB;
ALTER TABLE `newsletter_template` ENGINE=InnoDB;
#ALTER TABLE `oscommerce_import` ENGINE=InnoDB;
#ALTER TABLE `oscommerce_import_type` ENGINE=InnoDB;
#ALTER TABLE `oscommerce_orders` ENGINE=MyISAM;
#ALTER TABLE `oscommerce_orders_products` ENGINE=MyISAM;
#ALTER TABLE `oscommerce_orders_status_history` ENGINE=MyISAM;
#ALTER TABLE `oscommerce_orders_total` ENGINE=MyISAM;
#ALTER TABLE `oscommerce_ref` ENGINE=InnoDB;
#ALTER TABLE `paybox_api_debug` ENGINE=InnoDB;
#ALTER TABLE `paybox_question_number` ENGINE=InnoDB;
ALTER TABLE `paygate_authorizenet_debug` ENGINE=MyISAM;
ALTER TABLE `paypal_api_debug` ENGINE=MyISAM;
ALTER TABLE `paypaluk_api_debug` ENGINE=InnoDB;
ALTER TABLE `poll` ENGINE=InnoDB;
ALTER TABLE `poll_answer` ENGINE=InnoDB;
ALTER TABLE `poll_store` ENGINE=InnoDB;
ALTER TABLE `poll_vote` ENGINE=InnoDB;
ALTER TABLE `product_alert_price` ENGINE=InnoDB;
ALTER TABLE `product_alert_stock` ENGINE=MyISAM;
ALTER TABLE `rating` ENGINE=InnoDB;
ALTER TABLE `rating_entity` ENGINE=InnoDB;
ALTER TABLE `rating_option` ENGINE=InnoDB;
ALTER TABLE `rating_option_vote` ENGINE=InnoDB;
ALTER TABLE `rating_option_vote_aggregated` ENGINE=InnoDB;
ALTER TABLE `rating_store` ENGINE=InnoDB;
ALTER TABLE `rating_title` ENGINE=InnoDB;
ALTER TABLE `report_event` ENGINE=InnoDB;
ALTER TABLE `report_event_types` ENGINE=InnoDB;
ALTER TABLE `review` ENGINE=InnoDB;
ALTER TABLE `review_detail` ENGINE=InnoDB;
ALTER TABLE `review_entity` ENGINE=InnoDB;
ALTER TABLE `review_entity_summary` ENGINE=InnoDB;
ALTER TABLE `review_status` ENGINE=InnoDB;
ALTER TABLE `review_store` ENGINE=InnoDB;
ALTER TABLE `sales_bestsellers_aggregated_daily` ENGINE=InnoDB;
ALTER TABLE `sales_bestsellers_aggregated_monthly` ENGINE=InnoDB;
ALTER TABLE `sales_bestsellers_aggregated_yearly` ENGINE=InnoDB;
ALTER TABLE `sales_billing_agreement` ENGINE=InnoDB;
ALTER TABLE `sales_billing_agreement_order` ENGINE=InnoDB;
ALTER TABLE `sales_flat_creditmemo` ENGINE=InnoDB;
ALTER TABLE `sales_flat_creditmemo_comment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_creditmemo_grid` ENGINE=InnoDB;
ALTER TABLE `sales_flat_creditmemo_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_invoice` ENGINE=InnoDB;
ALTER TABLE `sales_flat_invoice_comment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_invoice_grid` ENGINE=InnoDB;
ALTER TABLE `sales_flat_invoice_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_address` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_grid` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_payment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_shipping_rate` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_status_history` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_address` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_address_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_item_option` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_payment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_shipping_rate` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment_comment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment_grid` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment_track` ENGINE=InnoDB;
ALTER TABLE `sales_invoiced_aggregated` ENGINE=InnoDB;
ALTER TABLE `sales_invoiced_aggregated_order` ENGINE=InnoDB;
ALTER TABLE `sales_order_aggregated_created` ENGINE=InnoDB;
ALTER TABLE `sales_order_tax` ENGINE=InnoDB;
ALTER TABLE `sales_payment_transaction` ENGINE=InnoDB;
ALTER TABLE `sales_recurring_profile` ENGINE=InnoDB;
ALTER TABLE `sales_recurring_profile_order` ENGINE=InnoDB;
ALTER TABLE `sales_refunded_aggregated` ENGINE=InnoDB;
ALTER TABLE `sales_refunded_aggregated_order` ENGINE=InnoDB;
ALTER TABLE `sales_shipping_aggregated` ENGINE=InnoDB;
ALTER TABLE `sales_shipping_aggregated_order` ENGINE=InnoDB;
ALTER TABLE `salesrule` ENGINE=InnoDB;
ALTER TABLE `salesrule_coupon` ENGINE=InnoDB;
ALTER TABLE `salesrule_coupon_usage` ENGINE=InnoDB;
ALTER TABLE `salesrule_customer` ENGINE=InnoDB;
ALTER TABLE `salesrule_label` ENGINE=InnoDB;
ALTER TABLE `sendfriend_log` ENGINE=MyISAM;
ALTER TABLE `shipping_tablerate` ENGINE=InnoDB;
ALTER TABLE `sitemap` ENGINE=InnoDB;
ALTER TABLE `tag` ENGINE=InnoDB;
ALTER TABLE `tag_relation` ENGINE=InnoDB;
ALTER TABLE `tag_summary` ENGINE=InnoDB;
ALTER TABLE `tax_calculation` ENGINE=InnoDB;
ALTER TABLE `tax_calculation_rate` ENGINE=InnoDB;
ALTER TABLE `tax_calculation_rate_title` ENGINE=InnoDB;
ALTER TABLE `tax_calculation_rule` ENGINE=InnoDB;
ALTER TABLE `tax_class` ENGINE=InnoDB;
ALTER TABLE `weee_discount` ENGINE=InnoDB;
ALTER TABLE `weee_tax` ENGINE=InnoDB;
ALTER TABLE `wishlist` ENGINE=InnoDB;
ALTER TABLE `wishlist_item` ENGINE=InnoDB;
ALTER TABLE `admin_role` ENGINE=InnoDB;
ALTER TABLE `admin_rule` ENGINE=InnoDB;
ALTER TABLE `admin_user` ENGINE=InnoDB;
ALTER TABLE `adminnotification_inbox` ENGINE=InnoDB;
ALTER TABLE `api_assert` ENGINE=InnoDB;
ALTER TABLE `api_role` ENGINE=InnoDB;
ALTER TABLE `api_rule` ENGINE=InnoDB;
ALTER TABLE `api_user` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_int` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_text` ENGINE=InnoDB;
ALTER TABLE `catalog_category_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `catalog_category_product` ENGINE=InnoDB;
ALTER TABLE `catalog_category_product_index` ENGINE=InnoDB;
ALTER TABLE `catalog_compare_item` ENGINE=InnoDB;
ALTER TABLE `catalog_product_bundle_option` ENGINE=InnoDB;
ALTER TABLE `catalog_product_bundle_option_value` ENGINE=InnoDB;
ALTER TABLE `catalog_product_bundle_selection` ENGINE=InnoDB;
ALTER TABLE `catalog_product_enabled_index` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_gallery` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_int` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_media_gallery` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_media_gallery_value` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_text` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_tier_price` ENGINE=InnoDB;
ALTER TABLE `catalog_product_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_attribute` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_attribute_decimal` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_attribute_int` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_attribute_varchar` ENGINE=InnoDB;
ALTER TABLE `catalog_product_link_type` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_price` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_title` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_type_price` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_type_title` ENGINE=InnoDB;
ALTER TABLE `catalog_product_option_type_value` ENGINE=InnoDB;
ALTER TABLE `catalog_product_super_attribute` ENGINE=InnoDB;
ALTER TABLE `catalog_product_super_attribute_label` ENGINE=InnoDB;
ALTER TABLE `catalog_product_super_attribute_pricing` ENGINE=InnoDB;
ALTER TABLE `catalog_product_super_link` ENGINE=InnoDB;
ALTER TABLE `catalog_product_website` ENGINE=InnoDB;
ALTER TABLE `catalogindex_aggregation` ENGINE=InnoDB;
ALTER TABLE `catalogindex_aggregation_tag` ENGINE=InnoDB;
ALTER TABLE `catalogindex_aggregation_to_tag` ENGINE=InnoDB;
ALTER TABLE `catalogindex_eav` ENGINE=InnoDB;
ALTER TABLE `catalogindex_minimal_price` ENGINE=InnoDB;
ALTER TABLE `catalogindex_price` ENGINE=InnoDB;
ALTER TABLE `cataloginventory_stock` ENGINE=InnoDB;
ALTER TABLE `cataloginventory_stock_item` ENGINE=InnoDB;
ALTER TABLE `catalogrule` ENGINE=InnoDB;
ALTER TABLE `catalogrule_affected_product` ENGINE=InnoDB;
ALTER TABLE `catalogrule_product` ENGINE=InnoDB;
ALTER TABLE `catalogrule_product_price` ENGINE=InnoDB;
ALTER TABLE `catalogsearch_fulltext` ENGINE=MyISAM;
ALTER TABLE `catalogsearch_query` ENGINE=InnoDB;
ALTER TABLE `catalogsearch_result` ENGINE=InnoDB;
ALTER TABLE `checkout_agreement` ENGINE=InnoDB;
ALTER TABLE `checkout_agreement_store` ENGINE=InnoDB;
ALTER TABLE `cms_block` ENGINE=InnoDB;
ALTER TABLE `cms_block_store` ENGINE=InnoDB;
ALTER TABLE `cms_page` ENGINE=InnoDB;
ALTER TABLE `cms_page_store` ENGINE=InnoDB;
ALTER TABLE `core_config_data` ENGINE=InnoDB;
ALTER TABLE `core_email_template` ENGINE=InnoDB;
ALTER TABLE `core_flag` ENGINE=InnoDB;
ALTER TABLE `core_layout_link` ENGINE=InnoDB;
ALTER TABLE `core_layout_update` ENGINE=InnoDB;
ALTER TABLE `core_resource` ENGINE=InnoDB;
ALTER TABLE `core_session` ENGINE=InnoDB;
ALTER TABLE `core_store` ENGINE=InnoDB;
ALTER TABLE `core_store_group` ENGINE=InnoDB;
ALTER TABLE `core_translate` ENGINE=InnoDB;
ALTER TABLE `core_url_rewrite` ENGINE=InnoDB;
ALTER TABLE `core_website` ENGINE=InnoDB;
ALTER TABLE `cron_schedule` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_int` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_text` ENGINE=InnoDB;
ALTER TABLE `customer_address_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `customer_entity` ENGINE=InnoDB;
ALTER TABLE `customer_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `customer_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `customer_entity_int` ENGINE=InnoDB;
ALTER TABLE `customer_entity_text` ENGINE=InnoDB;
ALTER TABLE `customer_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `customer_group` ENGINE=InnoDB;
ALTER TABLE `dataflow_batch` ENGINE=InnoDB;
ALTER TABLE `dataflow_batch_export` ENGINE=InnoDB;
ALTER TABLE `dataflow_batch_import` ENGINE=InnoDB;
ALTER TABLE `dataflow_import_data` ENGINE=InnoDB;
ALTER TABLE `dataflow_profile` ENGINE=InnoDB;
ALTER TABLE `dataflow_profile_history` ENGINE=InnoDB;
ALTER TABLE `dataflow_session` ENGINE=InnoDB;
ALTER TABLE `design_change` ENGINE=InnoDB;
ALTER TABLE `directory_country` ENGINE=InnoDB;
ALTER TABLE `directory_country_format` ENGINE=InnoDB;
ALTER TABLE `directory_country_region` ENGINE=InnoDB;
ALTER TABLE `directory_country_region_name` ENGINE=InnoDB;
ALTER TABLE `directory_currency_rate` ENGINE=InnoDB;
ALTER TABLE `downloadable_link` ENGINE=InnoDB;
ALTER TABLE `downloadable_link_price` ENGINE=InnoDB;
ALTER TABLE `downloadable_link_purchased` ENGINE=InnoDB;
ALTER TABLE `downloadable_link_purchased_item` ENGINE=InnoDB;
ALTER TABLE `downloadable_link_title` ENGINE=InnoDB;
ALTER TABLE `downloadable_sample` ENGINE=InnoDB;
ALTER TABLE `downloadable_sample_title` ENGINE=InnoDB;
ALTER TABLE `eav_attribute` ENGINE=InnoDB;
ALTER TABLE `eav_attribute_group` ENGINE=InnoDB;
ALTER TABLE `eav_attribute_option` ENGINE=InnoDB;
ALTER TABLE `eav_attribute_option_value` ENGINE=InnoDB;
ALTER TABLE `eav_attribute_set` ENGINE=InnoDB;
ALTER TABLE `eav_entity` ENGINE=InnoDB;
ALTER TABLE `eav_entity_attribute` ENGINE=InnoDB;
ALTER TABLE `eav_entity_datetime` ENGINE=InnoDB;
ALTER TABLE `eav_entity_decimal` ENGINE=InnoDB;
ALTER TABLE `eav_entity_int` ENGINE=InnoDB;
ALTER TABLE `eav_entity_store` ENGINE=InnoDB;
ALTER TABLE `eav_entity_text` ENGINE=InnoDB;
ALTER TABLE `eav_entity_type` ENGINE=InnoDB;
ALTER TABLE `eav_entity_varchar` ENGINE=InnoDB;
ALTER TABLE `gift_message` ENGINE=InnoDB;
ALTER TABLE `googlebase_attributes` ENGINE=InnoDB;
ALTER TABLE `googlebase_items` ENGINE=InnoDB;
ALTER TABLE `googlebase_types` ENGINE=InnoDB;
ALTER TABLE `googlecheckout_api_debug` ENGINE=InnoDB;
ALTER TABLE `googleoptimizer_code` ENGINE=InnoDB;
ALTER TABLE `log_customer` ENGINE=MyISAM;
ALTER TABLE `log_quote` ENGINE=MyISAM;
ALTER TABLE `log_summary` ENGINE=MyISAM;
ALTER TABLE `log_summary_type` ENGINE=MyISAM;
ALTER TABLE `log_url` ENGINE=MyISAM;
ALTER TABLE `log_url_info` ENGINE=MyISAM;
ALTER TABLE `log_visitor` ENGINE=MyISAM;
ALTER TABLE `log_visitor_info` ENGINE=MyISAM;
ALTER TABLE `newsletter_problem` ENGINE=InnoDB;
ALTER TABLE `newsletter_queue` ENGINE=InnoDB;
ALTER TABLE `newsletter_queue_link` ENGINE=InnoDB;
ALTER TABLE `newsletter_queue_store_link` ENGINE=InnoDB;
ALTER TABLE `newsletter_subscriber` ENGINE=InnoDB;
ALTER TABLE `newsletter_template` ENGINE=InnoDB;
#ALTER TABLE `oscommerce_import` ENGINE=InnoDB;
#ALTER TABLE `oscommerce_import_type` ENGINE=InnoDB;
#ALTER TABLE `oscommerce_orders` ENGINE=MyISAM;
#ALTER TABLE `oscommerce_orders_products` ENGINE=MyISAM;
#ALTER TABLE `oscommerce_orders_status_history` ENGINE=MyISAM;
#ALTER TABLE `oscommerce_orders_total` ENGINE=MyISAM;
#ALTER TABLE `oscommerce_ref` ENGINE=InnoDB;
#ALTER TABLE `paybox_api_debug` ENGINE=InnoDB;
#ALTER TABLE `paybox_question_number` ENGINE=InnoDB;
ALTER TABLE `paygate_authorizenet_debug` ENGINE=MyISAM;
ALTER TABLE `paypal_api_debug` ENGINE=MyISAM;
ALTER TABLE `paypaluk_api_debug` ENGINE=InnoDB;
ALTER TABLE `poll` ENGINE=InnoDB;
ALTER TABLE `poll_answer` ENGINE=InnoDB;
ALTER TABLE `poll_store` ENGINE=InnoDB;
ALTER TABLE `poll_vote` ENGINE=InnoDB;
ALTER TABLE `product_alert_price` ENGINE=InnoDB;
ALTER TABLE `product_alert_stock` ENGINE=MyISAM;
ALTER TABLE `rating` ENGINE=InnoDB;
ALTER TABLE `rating_entity` ENGINE=InnoDB;
ALTER TABLE `rating_option` ENGINE=InnoDB;
ALTER TABLE `rating_option_vote` ENGINE=InnoDB;
ALTER TABLE `rating_option_vote_aggregated` ENGINE=InnoDB;
ALTER TABLE `rating_store` ENGINE=InnoDB;
ALTER TABLE `rating_title` ENGINE=InnoDB;
ALTER TABLE `report_event` ENGINE=InnoDB;
ALTER TABLE `report_event_types` ENGINE=InnoDB;
ALTER TABLE `review` ENGINE=InnoDB;
ALTER TABLE `review_detail` ENGINE=InnoDB;
ALTER TABLE `review_entity` ENGINE=InnoDB;
ALTER TABLE `review_entity_summary` ENGINE=InnoDB;
ALTER TABLE `review_status` ENGINE=InnoDB;
ALTER TABLE `review_store` ENGINE=InnoDB;
ALTER TABLE `sales_bestsellers_aggregated_daily` ENGINE=InnoDB;
ALTER TABLE `sales_bestsellers_aggregated_monthly` ENGINE=InnoDB;
ALTER TABLE `sales_bestsellers_aggregated_yearly` ENGINE=InnoDB;
ALTER TABLE `sales_billing_agreement` ENGINE=InnoDB;
ALTER TABLE `sales_billing_agreement_order` ENGINE=InnoDB;
ALTER TABLE `sales_flat_creditmemo` ENGINE=InnoDB;
ALTER TABLE `sales_flat_creditmemo_comment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_creditmemo_grid` ENGINE=InnoDB;
ALTER TABLE `sales_flat_creditmemo_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_invoice` ENGINE=InnoDB;
ALTER TABLE `sales_flat_invoice_comment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_invoice_grid` ENGINE=InnoDB;
ALTER TABLE `sales_flat_invoice_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_address` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_grid` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_payment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_shipping_rate` ENGINE=InnoDB;
ALTER TABLE `sales_flat_order_status_history` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_address` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_address_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_item_option` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_payment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_quote_shipping_rate` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment_comment` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment_grid` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment_item` ENGINE=InnoDB;
ALTER TABLE `sales_flat_shipment_track` ENGINE=InnoDB;
ALTER TABLE `sales_invoiced_aggregated` ENGINE=InnoDB;
ALTER TABLE `sales_invoiced_aggregated_order` ENGINE=InnoDB;
ALTER TABLE `sales_order_aggregated_created` ENGINE=InnoDB;
ALTER TABLE `sales_order_tax` ENGINE=InnoDB;
ALTER TABLE `sales_payment_transaction` ENGINE=InnoDB;
ALTER TABLE `sales_recurring_profile` ENGINE=InnoDB;
ALTER TABLE `sales_recurring_profile_order` ENGINE=InnoDB;
ALTER TABLE `sales_refunded_aggregated` ENGINE=InnoDB;
ALTER TABLE `sales_refunded_aggregated_order` ENGINE=InnoDB;
ALTER TABLE `sales_shipping_aggregated` ENGINE=InnoDB;
ALTER TABLE `sales_shipping_aggregated_order` ENGINE=InnoDB;
ALTER TABLE `salesrule` ENGINE=InnoDB;
ALTER TABLE `salesrule_coupon` ENGINE=InnoDB;
ALTER TABLE `salesrule_coupon_usage` ENGINE=InnoDB;
ALTER TABLE `salesrule_customer` ENGINE=InnoDB;
ALTER TABLE `salesrule_label` ENGINE=InnoDB;
ALTER TABLE `sendfriend_log` ENGINE=MyISAM;
ALTER TABLE `shipping_tablerate` ENGINE=InnoDB;
ALTER TABLE `sitemap` ENGINE=InnoDB;
ALTER TABLE `tag` ENGINE=InnoDB;
ALTER TABLE `tag_relation` ENGINE=InnoDB;
ALTER TABLE `tag_summary` ENGINE=InnoDB;
ALTER TABLE `tax_calculation` ENGINE=InnoDB;
ALTER TABLE `tax_calculation_rate` ENGINE=InnoDB;
ALTER TABLE `tax_calculation_rate_title` ENGINE=InnoDB;
ALTER TABLE `tax_calculation_rule` ENGINE=InnoDB;
ALTER TABLE `tax_class` ENGINE=InnoDB;
ALTER TABLE `weee_discount` ENGINE=InnoDB;
ALTER TABLE `weee_tax` ENGINE=InnoDB;
ALTER TABLE `wishlist` ENGINE=InnoDB;
ALTER TABLE `wishlist_item` ENGINE=InnoDB;
Different kind of catalog sorting (top selling,top rated, new products, special products) in magento
////////////////////////////////////
template/catalog/product/list/toolbar.phtml
<div class=”demoTarget toolbar”>
<span class=”pagingTotal”>Order:</span>
<?php /*?><select onchange=”setLocation(this.value)” id=”default-usage-selectdate”>
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value=”<?php echo $this->getOrderUrl($_key, ‘asc’) ?>”<?php if($this->isOrderCurrent($_key)): ?> selected=”selected”<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select><?php */?>
<?php $orderDir = $this->getRequest()->getParam(‘dir’);?>
<select onchange=”setLocation(this.value)” id=”default-usage-selectdate”>
<option value=”<?php echo $this->getOrderUrl(‘topsellings’, ‘desc’) ?>”<?php if($this->isOrderCurrent(‘topsellings’)): ?> selected=”selected”<?php endif; ?>>
Top Selling
</option>
<option value=”<?php echo $this->getOrderUrl(‘special_price’, ‘desc’) ?>”<?php if($this->isOrderCurrent(‘special_price’)): ?> selected=”selected”<?php endif; ?>>
Special Orice
</option>
<option value=”<?php echo $this->getOrderUrl(‘newest’, ‘desc’) ?>”<?php if($this->isOrderCurrent(‘newest’)): ?> selected=”selected”<?php endif; ?>>
New Products
</option>
<option value=”<?php echo $this->getOrderUrl(‘popularity’, ‘desc’) ?>”<?php if($this->isOrderCurrent(‘popularity’)): ?> selected=”selected”<?php endif; ?>>
Popularity (Most Rated)
</option>
</select>
<div class=”clr”></div>
</div>
——————————————————————————–
D:\xampp\htdocs\lamemo\live\app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php
in function setCollection() put below code
————————————————-
<?php
if($this->getCurrentOrder() == ‘popularity’){
$this->_collection->joinField(‘rating_score’,
‘lamemoreview_entity_summary’,
‘rating_summary’,
‘entity_pk_value=entity_id’,
array(‘entity_type’=>1, ‘store_id’=> Mage::app()->getStore()->getId()),
‘left’
)->setOrder(‘rating_score’, $this->getCurrentDirection());
}
elseif($this->getCurrentOrder() ==’special_price’)
{
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
/*$this->_collection->addAttributeToFilter(‘special_from_date’, array(‘or’=> array(
0 => array(‘date’ => true, ‘to’ => $todayDate),
1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
))->addAttributeToFilter(‘special_to_date’, array(‘or’=> array(
0 => array(‘date’ => true, ‘from’ => $todayDate),
1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
))->addAttributeToSort(‘special_price’, ‘DESC’);*/
/*$this->_collection->joinTable(‘lamemocatalog_product_flat_1′,’entity_id=entity_id’,array(‘goodcustom’=>”abs (lamemocatalog_product_flat_1.special_from_date <= ‘”.$todayDate.”‘ and (lamemocatalog_product_flat_1.special_to_date >= ‘”.$todayDate.”‘ or lamemocatalog_product_flat_1.special_to_date = NULL))”),NULL,’left’)->getSelect()->order(“goodcustom desc”);
echo $this->_collection->getSelect();*/
$this->_collection->joinTable(‘lamemocatalog_product_flat_1′,’entity_id=entity_id’,array(‘cust_ord_field’=>”IF((special_from_date <= ‘”.$todayDate.”‘ &&
(special_to_date >= ‘”.$todayDate.”‘ || isnull(special_to_date))),’yes’,'no’)”),NULL,’left’);
$this->_collection->getSelect()->order(“cust_ord_field desc”);
$this->_collection->getSelect()->order(“final_price asc”);
//echo $this->_collection->getSelect();
/*$this->_collection->addAttributeToFilter(‘special_from_date’, array(‘date’ => true, ‘to’ => $todayDate))
->addAttributeToFilter(‘special_to_date’, array(‘or’=> array(
0 => array(‘date’ => true, ‘from’ => $todayDate),
1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
), ‘left’)->addAttributeToSort(‘special_price’, ‘ASC’);*/
}
elseif($this->getCurrentOrder() == ‘newest’){
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
/*$this->_collection->addAttributeToFilter(‘news_from_date’, array(‘date’ => true, ‘to’ => $todayDate))
->addAttributeToFilter(‘news_to_date’, array(‘or’=> array(
0 => array(‘date’ => true, ‘from’ => $todayDate),
1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
), ‘left’)->setOrder(‘news_to_date’, $this->getCurrentDirection());;*/
/*$this->_collection->joinTable(‘lamemocatalog_product_flat_1′,’entity_id=entity_id’,array(‘goodcustom’=>”abs (lamemocatalog_product_flat_1.news_from_date <= ‘”.$todayDate.”‘ and lamemocatalog_product_flat_1.news_to_date >= ‘”.$todayDate.”‘)”),NULL,’left’)->getSelect()->order(“goodcustom desc”);
echo $this->_collection->getSelect();*/
$this->_collection->joinTable(‘lamemocatalog_product_flat_1′,’entity_id=entity_id’,array(‘cust_ord_field’=>”if(news_from_date <= ‘”.$todayDate.”‘ and
(news_to_date >= ‘”.$todayDate.”‘ || isnull(news_to_date)) ,’yes’,'no’)”),NULL,’left’);
$this->_collection->getSelect()->order(“cust_ord_field desc”);;
$this->_collection->getSelect()->order(“final_price desc”);;
//”news_from_date <= ‘”.$todayDate.”‘ and news_to_date >= ‘”.$todayDate.”‘ desc”
// echo $this->_collection->getSelect();
}
elseif($this->getCurrentOrder() == ‘topsellings’){
/* $this->_collection->getSelect()->
joinLeft(‘lamemosales_flat_order_item AS sfoi’,
‘e.entity_id = sfoi.product_id’,
‘SUM(sfoi.qty_ordered) AS ordered_qty’)->
group(‘e.entity_id’)->order(‘ordered_qty DESC’); */
create view
CREATE VIEW `salesitemsqty` AS select `lamemosales_flat_order_item`.`product_id` AS `product_id`,count(0) AS `ord_qty` from `lamemosales_flat_order_item` group by `lamemosales_flat_order_item`.`product_id`
$this->_collection->joinTable(‘salesitemsqty’,'product_id=entity_id’,array(‘tqty_ordered’=>’ord_qty’),NULL,’left’)->setOrder(‘tqty_ordered’, $this->getCurrentDirection());
/*$this->_collection->joinField(‘ordered_qty’,
‘lamemosales_flat_order_item’,
‘SUM(qty_ordered) AS ordered_qty’,
‘product_id = entity_id’,
array(‘store_id’=> Mage::app()->getStore()->getId()),
‘left’
)->setOrder(‘ordered_qty’, $this->getCurrentDirection()); */
/*$storeId = Mage::app()->getStore()->getId();
$products = Mage::getResourceModel(‘reports/product_collection’)
->addOrderedQty()
->addAttributeToSelect(‘*’) //Need this so products show up correctly in product listing
->setStoreId($storeId)
->addStoreFilter($storeId);
Mage::getSingleton(‘catalog/product_status’)->addVisibleFilterToCollection($products);
Mage::getSingleton(‘catalog/product_visibility’)->addVisibleInCatalogFilterToCollection($products);*/
}
?>
template/catalog/product/list/toolbar.phtml
<div class=”demoTarget toolbar”>
<span class=”pagingTotal”>Order:</span>
<?php /*?><select onchange=”setLocation(this.value)” id=”default-usage-selectdate”>
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value=”<?php echo $this->getOrderUrl($_key, ‘asc’) ?>”<?php if($this->isOrderCurrent($_key)): ?> selected=”selected”<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select><?php */?>
<?php $orderDir = $this->getRequest()->getParam(‘dir’);?>
<select onchange=”setLocation(this.value)” id=”default-usage-selectdate”>
<option value=”<?php echo $this->getOrderUrl(‘topsellings’, ‘desc’) ?>”<?php if($this->isOrderCurrent(‘topsellings’)): ?> selected=”selected”<?php endif; ?>>
Top Selling
</option>
<option value=”<?php echo $this->getOrderUrl(‘special_price’, ‘desc’) ?>”<?php if($this->isOrderCurrent(‘special_price’)): ?> selected=”selected”<?php endif; ?>>
Special Orice
</option>
<option value=”<?php echo $this->getOrderUrl(‘newest’, ‘desc’) ?>”<?php if($this->isOrderCurrent(‘newest’)): ?> selected=”selected”<?php endif; ?>>
New Products
</option>
<option value=”<?php echo $this->getOrderUrl(‘popularity’, ‘desc’) ?>”<?php if($this->isOrderCurrent(‘popularity’)): ?> selected=”selected”<?php endif; ?>>
Popularity (Most Rated)
</option>
</select>
<div class=”clr”></div>
</div>
——————————————————————————–
D:\xampp\htdocs\lamemo\live\app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php
in function setCollection() put below code
————————————————-
<?php
if($this->getCurrentOrder() == ‘popularity’){
$this->_collection->joinField(‘rating_score’,
‘lamemoreview_entity_summary’,
‘rating_summary’,
‘entity_pk_value=entity_id’,
array(‘entity_type’=>1, ‘store_id’=> Mage::app()->getStore()->getId()),
‘left’
)->setOrder(‘rating_score’, $this->getCurrentDirection());
}
elseif($this->getCurrentOrder() ==’special_price’)
{
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
/*$this->_collection->addAttributeToFilter(‘special_from_date’, array(‘or’=> array(
0 => array(‘date’ => true, ‘to’ => $todayDate),
1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
))->addAttributeToFilter(‘special_to_date’, array(‘or’=> array(
0 => array(‘date’ => true, ‘from’ => $todayDate),
1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
))->addAttributeToSort(‘special_price’, ‘DESC’);*/
/*$this->_collection->joinTable(‘lamemocatalog_product_flat_1′,’entity_id=entity_id’,array(‘goodcustom’=>”abs (lamemocatalog_product_flat_1.special_from_date <= ‘”.$todayDate.”‘ and (lamemocatalog_product_flat_1.special_to_date >= ‘”.$todayDate.”‘ or lamemocatalog_product_flat_1.special_to_date = NULL))”),NULL,’left’)->getSelect()->order(“goodcustom desc”);
echo $this->_collection->getSelect();*/
$this->_collection->joinTable(‘lamemocatalog_product_flat_1′,’entity_id=entity_id’,array(‘cust_ord_field’=>”IF((special_from_date <= ‘”.$todayDate.”‘ &&
(special_to_date >= ‘”.$todayDate.”‘ || isnull(special_to_date))),’yes’,'no’)”),NULL,’left’);
$this->_collection->getSelect()->order(“cust_ord_field desc”);
$this->_collection->getSelect()->order(“final_price asc”);
//echo $this->_collection->getSelect();
/*$this->_collection->addAttributeToFilter(‘special_from_date’, array(‘date’ => true, ‘to’ => $todayDate))
->addAttributeToFilter(‘special_to_date’, array(‘or’=> array(
0 => array(‘date’ => true, ‘from’ => $todayDate),
1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
), ‘left’)->addAttributeToSort(‘special_price’, ‘ASC’);*/
}
elseif($this->getCurrentOrder() == ‘newest’){
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
/*$this->_collection->addAttributeToFilter(‘news_from_date’, array(‘date’ => true, ‘to’ => $todayDate))
->addAttributeToFilter(‘news_to_date’, array(‘or’=> array(
0 => array(‘date’ => true, ‘from’ => $todayDate),
1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
), ‘left’)->setOrder(‘news_to_date’, $this->getCurrentDirection());;*/
/*$this->_collection->joinTable(‘lamemocatalog_product_flat_1′,’entity_id=entity_id’,array(‘goodcustom’=>”abs (lamemocatalog_product_flat_1.news_from_date <= ‘”.$todayDate.”‘ and lamemocatalog_product_flat_1.news_to_date >= ‘”.$todayDate.”‘)”),NULL,’left’)->getSelect()->order(“goodcustom desc”);
echo $this->_collection->getSelect();*/
$this->_collection->joinTable(‘lamemocatalog_product_flat_1′,’entity_id=entity_id’,array(‘cust_ord_field’=>”if(news_from_date <= ‘”.$todayDate.”‘ and
(news_to_date >= ‘”.$todayDate.”‘ || isnull(news_to_date)) ,’yes’,'no’)”),NULL,’left’);
$this->_collection->getSelect()->order(“cust_ord_field desc”);;
$this->_collection->getSelect()->order(“final_price desc”);;
//”news_from_date <= ‘”.$todayDate.”‘ and news_to_date >= ‘”.$todayDate.”‘ desc”
// echo $this->_collection->getSelect();
}
elseif($this->getCurrentOrder() == ‘topsellings’){
/* $this->_collection->getSelect()->
joinLeft(‘lamemosales_flat_order_item AS sfoi’,
‘e.entity_id = sfoi.product_id’,
‘SUM(sfoi.qty_ordered) AS ordered_qty’)->
group(‘e.entity_id’)->order(‘ordered_qty DESC’); */
create view
CREATE VIEW `salesitemsqty` AS select `lamemosales_flat_order_item`.`product_id` AS `product_id`,count(0) AS `ord_qty` from `lamemosales_flat_order_item` group by `lamemosales_flat_order_item`.`product_id`
$this->_collection->joinTable(‘salesitemsqty’,'product_id=entity_id’,array(‘tqty_ordered’=>’ord_qty’),NULL,’left’)->setOrder(‘tqty_ordered’, $this->getCurrentDirection());
/*$this->_collection->joinField(‘ordered_qty’,
‘lamemosales_flat_order_item’,
‘SUM(qty_ordered) AS ordered_qty’,
‘product_id = entity_id’,
array(‘store_id’=> Mage::app()->getStore()->getId()),
‘left’
)->setOrder(‘ordered_qty’, $this->getCurrentDirection()); */
/*$storeId = Mage::app()->getStore()->getId();
$products = Mage::getResourceModel(‘reports/product_collection’)
->addOrderedQty()
->addAttributeToSelect(‘*’) //Need this so products show up correctly in product listing
->setStoreId($storeId)
->addStoreFilter($storeId);
Mage::getSingleton(‘catalog/product_status’)->addVisibleFilterToCollection($products);
Mage::getSingleton(‘catalog/product_visibility’)->addVisibleInCatalogFilterToCollection($products);*/
}
?>
Subscribe to:
Posts (Atom)