<?php $this->setProduct(Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($_product->getId()))?>
<?php echo $this->getTierPriceHtml() ?>
It does not look nice for grid but it can be fixed by css.
<?php $this->setProduct(Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($_product->getId()))?>
<?php echo $this->getTierPriceHtml() ?>
<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
Mage::register('isSecureArea', 1);
//until here you gained access to the Magento models. The rest is custom code
$orderId = 156;//put here the id of the order you want to delete. THE ONE FROM THE DATABASE NOT THE INCREMENT_ID
$order = Mage::getModel('sales/order')->load($orderId);
$invoices = $order->getInvoiceCollection();
foreach ($invoices as $invoice){
$invoice->delete();
}
$creditnotes = $order->getCreditmemosCollection();
foreach ($creditnotes as $creditnote){
$creditnote->delete();
}
$shipments = $order->getShipmentsCollection();
foreach ($shipments as $shipment){
$shipment->delete();
}
$order->delete();
?>
Save and call it in your browser (http://my-magento.root/orders.php)//let's say that the orders with ids less than 200 are test orders
$collection = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter(array(array('attribute'=>'entity_id', 'lt'=>200)));
foreach ($collection as $o){
$orderId = $o->getId();
//here goes the code above starting below $orderId = 156.
}
//for related $_product->setRelatedLinkData($param); //for up-sells $_product->setUpSellLinkData($param); //for crosssells $_product->setCrossSellLinkData($param);$param is an array with the following structure
$param = array( $associatedProductId=>array( 'position'=>$associatedProductPosition ) )
$param = array( 101=>array( 'position'=>3 ), 102=>array( 'position'=>5 ) ); $_product->setRelatedLinkData($param); //here ... some other product operations and in the end $_product->save();
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
before you call $product->save();
INSERT INTO `eav_attribute` (`attribute_id`, `entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`, `is_user_defined`, `default_value`, `is_unique`, `note`) VALUES (NULL, 11, 'product_skus', NULL, NULL, 'varchar', NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, 0, '');
if (!$this->getProductSkus()) {
$skus = array();
foreach ($this->getAllItems() as $item) {
$skus[] = $item->getSku();
}
$this->setProductSkus(implode(",", $skus));
}
This will add a string with all the skus separated by comma to the order model.$this->addColumn('product_skus', array(
'header' => Mage::helper('sales')->__('Products'),
'index' => 'product_skus',
));
Added it where ever you want.<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
Mage::register('isSecureArea', 1);
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToSelect("*");
foreach ($orders as $order){
$order->save();
}
?>
INSERT INTO `eav_attribute` (`attribute_id`, `entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`, `is_user_defined`, `default_value`, `is_unique`, `note`) VALUES (NULL, 11, 'order_payment_method', NULL, NULL, 'varchar', NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, 0, '');Clear the cache.
if (!$this->getOrderPaymentMethod()) {
$this->setOrderPaymentMethod($this->getPayment()->getMethodInstance()->getTitle()); //if you want the payment method's name (Check / money order)
//$this->setOrderPaymentMethod($this->getPayment()->getMethod());//if you want the payment method's code (checkmo)
}
$this->addColumn('order_payment_method', array(
'header' => Mage::helper('sales')->__('Payment'),
'index' => 'order_payment_method',
));
$mailTemplate->setDesignConfig(array('area'=>'frontend', 'store' => $this->getStoreId()))
->sendTransactional(
$template,
Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_IDENTITY, $this->getStoreId()),
$recipient['email'],
$recipient['name'],
array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'comment' => $comment
)
);
to this:$mailTemplate->setDesignConfig(array('area'=>'frontend', 'store' => $this->getStoreId()))
->sendTransactional(
$template,
Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_IDENTITY, $this->getStoreId()),
$recipient['email'],
$recipient['name'],
array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'comment' => $comment,
'your_var_name'=>'SOMETHNG'
)
);
{{var your_var_name}}
<block type="core/text_list" name="top" as="top" translate="label"> <label>Top Row</label> </block>Now go to admin panel: Cms->Pages and edit the homepage.
<reference name="top"> <block type="core/template" name="top.callout" template="callouts/top_callout.phtml" /> </reference>You can put every block you want here. I just used this as an example. Just put it inside
<reference name="top"> .... </reference>Now edit app/design/frontend/{interface}/{theme}/template/page/3columns.phtml
<?php echo $this->getChildHtml('top') ?>
right under <?php echo $this->getChildHtml('header') ?>
Save all files you edited and clear the contents of 'var/cache/'protected $_canCapture = true;You can add it right under
protected $_code = 'PAYMENT CODE HERE';For example if you want to do this for Check/money order you need to add the line above in app/code/core/Mage/Payment/Model/Method/Checkmo.php
<block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>It should be inside of an other <block> tag named footer.
<block type="page/html_header" name="header" as="header"> <block type="page/template_links" name="top.links" as="topLinks"/> <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/> <block type="core/text_list" name="top.menu" as="topMenu"/> </block>AFTER:
<block type="page/html_header" name="header" as="header"> <block type="page/template_links" name="top.links" as="topLinks"/> <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/> <block type="core/text_list" name="top.menu" as="topMenu"/> <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/> </block>
<?php echo $this->getChildHtml('footer_links') ?>
Clear the contents of dir var/cache and it should work. You might need to do some css work so the new added links would look nice.
<reference name="left"> <block type="customer/form_login" name="customer_mini_login" before="-" template="customer/form/mini.login.phtml"/> </reference>Clear the cache and refresh.
$this->getLayout()->getBlock('head')->setTitle(Mage::helper('customer')->__('Customer Login'));
or remove the method completely (same effect).protected function _prepareLayout()
{
return $this;
}
<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
Mage::register('isSecureArea', 1);
function generateUniqueId($length = null){
$rndId = crypt(uniqid(rand(),1));
$rndId = strip_tags(stripslashes($rndId));
$rndId = str_replace(array(".", "$"),"",$rndId);
$rndId = strrev(str_replace("/","",$rndId));
if (!is_null($rndId)){
return strtoupper(substr($rndId, 0, $length));
}
return strtoupper($rndId);
}
function getAllCustomerGroups(){
//get all customer groups
$customerGroups = Mage::getModel('customer/group')->getCollection();
$groups = array();
foreach ($customerGroups as $group){
$groups[] = $group->getId();
}
return $groups;
}
function getAllWbsites(){
//get all wabsites
$websites = Mage::getModel('core/website')->getCollection();
$websiteIds = array();
foreach ($websites as $website){
$websiteIds[] = $website->getId();
}
return $websiteIds;
}
//read comments for each line
function generateRule(){
$uniqueId = generateUniqueId(10);
$rule = Mage::getModel('salesrule/rule');
$rule->setName($uniqueId);
$rule->setDescription('Generated by tzyganu');
$rule->setFromDate(date('Y-m-d'));//starting today
//$rule->setToDate('2011-01-01');//if you need an expiration date
$rule->setCouponCode($uniqueId);
$rule->setUsesPerCoupon(1);//number of allowed uses for this coupon
$rule->setUsesPerCustomer(1);//number of allowed uses for this coupon for each customer
$rule->setCustomerGroupIds(getAllCustomerGroups());//if you want only certain groups replace getAllCustomerGroups() with an array of desired ids
$rule->setIsActive(1);
$rule->setStopRulesProcessing(0);//set to 1 if you want all other rules after this to not be processed
$rule->setIsRss(0);//set to 1 if you want this rule to be public in rss
$rule->setIsAdvanced(1);//have no idea what it means :)
$rule->setProductIds('');
$rule->setSortOrder(0);// order in which the rules will be applied
$rule->setSimpleAction('by_percent');
//all available discount types
//by_percent - Percent of product price discount
//by_fixed - Fixed amount discount
//cart_fixed - Fixed amount discount for whole cart
//buy_x_get_y - Buy X get Y free (discount amount is Y)
$rule->setDiscountAmount('20');//the discount amount/percent. if SimpleAction is by_percent this value must be <= 100
$rule->setDiscountQty(0);//Maximum Qty Discount is Applied to
$rule->setDiscountStep(0);//used for buy_x_get_y; This is X
$rule->setSimpleFreeShipping(0);//set to 1 for Free shipping
$rule->setApplyToShipping(1);//set to 0 if you don't want the rule to be applied to shipping
$rule->setWebsiteIds(getAllWbsites());//if you want only certain websites replace getAllWbsites() with an array of desired ids
$conditions = array();
$conditions[1] = array(
'type' => 'salesrule/rule_condition_combine',
'aggregator' => 'all',
'value' => "1", //[UPDATE] added quotes on the value. Thanks Aziz Rattani [/UPDATE]
'new_child' => ''
);
//the conditions above are for 'if all of these conditions are true'
//for if any one of the conditions is true set 'aggregator' to 'any'
//for if all of the conditions are false set 'value' to 0.
//for if any one of the conditions is false set 'aggregator' to 'any' and 'value' to 0
$conditions['1--1'] = Array
(
'type' => 'salesrule/rule_condition_address',
'attribute' => 'base_subtotal',
'operator' => '>=',
'value' => 200
);
//the constraints above are for 'Subtotal is equal or grater than 200'
//for 'equal or less than' set 'operator' to '<='... You get the idea other operators for numbers: '==', '!=', '>', '<'
//for 'is one of' set operator to '()';
//for 'is not one of' set operator to '!()';
//in this example the constraint is on the subtotal
//for other attributes you can change the value for 'attribute' to: 'total_qty', 'weight', 'payment_method', 'shipping_method', 'postcode', 'region', 'region_id', 'country_id'
//to add an other constraint on product attributes (not cart attributes like above) uncomment and change the following:
/*
$conditions['1--2'] = array
(
'type' => 'salesrule/rule_condition_product_found',//-> means 'if all of the following are true' - same rules as above for 'aggregator' and 'value'
//other values for type: 'salesrule/rule_condition_product_subselect' 'salesrule/rule_condition_combine'
'value' => 1,
'aggregator' => 'all',
'new_child' => '',
);
$conditions['1--2--1'] = array
(
'type' => 'salesrule/rule_condition_product',
'attribute' => 'sku',
'operator' => '==',
'value' => '12',
);
*/
//$conditions['1--2--1'] means sku equals 12. For other constraints change 'attribute', 'operator'(see list above), 'value'
$rule->setData('conditions',$conditions);
$rule->loadPost($rule->getData());
$rule->save();
//[UPDATE]if you work with Mangento EE and you want to link banners to your rule uncomment the line of code below
//Mage::getResourceModel('enterprise_banner/banner')->bindBannersToSalesRule($rule->getId(), array(1,2));//the array(1,2, ...) is the array with all the banners you want to link to the rule.
//[/UPDATE]
}
?>
$rule->setCouponType(2);Add it just before
$rule->save();(Thanks Raj for pointing this out).
$labels = array(); $labels[0] = 'Default store label';//default store label $labels[1] = 'Label for store with id 1'; //.... $labels[n] = 'Label for store with id n'; //add one line for each store view you have. The key is the store view ID
$rule->setStoreLabels($labels);
for ($i=1;$i<=200;$i++){//replace 200 with the number of coupons you want
generateRule();
}
[UPDATE 1.2]<?php if(false): ?>
<div class="fields">
<label for="shipping:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
<div class="input-box">
<input type="text" name="shipping[email]" id="shipping:email" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
</div>
</div>
<?php endif ?>
<?php
require_once 'path/to/app_dir/app/Mage.php';
Mage::app('default');
$product = Mage::getModel('catalog/product');
$product->setAttributeSetId('THE ATTRIBUTE SET YOU WANT TO USE');
$groupId = 'THE ID OF THE GROUP YOU WANT TO RETRIEVE';
$collection = $product->getAttributes($groupId, false);
foreach($collection as $attribute){
//do something with the attribute
}
?>
$this->addData(array( 'server_addr' => $helper->getServerAddr(true), 'remote_addr' => $helper->getRemoteAddr(true), ....and remove the 'true' parameters from the functions.
$this->addData(array( 'server_addr' => $helper->getServerAddr(), 'remote_addr' => $helper->getRemoteAddr(),This should save the ip addresses as strings.
public function render(Varien_Object $row)
{
return long2ip($row->getData($this->getColumn()->getIndex()));
}
topublic function render(Varien_Object $row)
{
return $row->getData($this->getColumn()->getIndex());
}
or to this, for backwards compatibility (to see the previous saved ip addresses) public function render(Varien_Object $row)
{
$val = $this->getColumn()->getIndex();
if (is_int($val)){
return long2ip($val);
}
return $val;
}
UPDATE some_table SET some_field = some_value WHERE id = some_id;The sql goes through but nothing gets updated.
if (!is_null($object->getId())) {...}
This means exactly what I explained above.public function save($alwaysInsert = false)
{
$this->_getResource()->beginTransaction();
try {
$this->_beforeSave();
$this->_getResource()->save($this, $alwaysInsert);
$this->_afterSave();
$this->_getResource()->commit();
}
catch (Exception $e){
$this->_getResource()->rollBack();
throw $e;
}
return $this;
}
public function save(Mage_Core_Model_Abstract $object, bool $alwaysInsert)
{
if ($object->isDeleted()) {
return $this->delete($object);
}
$this->_beforeSave($object);
$this->_checkUnique($object);
if (!is_null($object->getId()) && !$alwaysInsert) {
$condition = $this->_getWriteAdapter()->quoteInto($this->getIdFieldName().'=?', $object->getId());
$this->_getWriteAdapter()->update($this->getMainTable(), $this->_prepareDataForSave($object), $condition);
} else {
$this->_getWriteAdapter()->insert($this->getMainTable(), $this->_prepareDataForSave($object));
$object->setId($this->_getWriteAdapter()->lastInsertId($this->getMainTable()));
}
$this->_afterSave($object);
return $this;
}
<template_hints translate="label"> <label<Template Path Hints</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>20</sort_order> <show_in_default>0</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </template_hints>replace
<show_in_default>0</show_in_default>with
<show_in_default>1</show_in_default>and clear the cache
<template_hints_blocks translate="label"> <label>Add Block Names to Hints</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>21</sort_order> <show_in_default>0</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </template_hints_blocks>Be careful. When you enable these 2 from 'default config' you will also see template hints and block hints in the admin section.
function getMetaTitle(){
if (!$this->getData('meta_title')){
$this->setMetaTitle($this->getTitle());
}
return $this->getData('meta_title');
}
<?php
class Mage_Catalog_Block_Product_All extends Mage_Catalog_Block_Product_List
{
protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
$collection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('status', 1)
->addAttributeToFilter(array(array('attribute'=>'visibility', 'eq'=>"4")));
$this->_productCollection = $collection;
}
return $this->_productCollection;
}
}
?>
{{block type="catalog/product_all" template="catalog/product/list.phtml"}}
In the "Layout" field (from the 'Custom design' tab) select '2columns-left' (or any other design just don't leave it to 'empty')function getDescription(){
$processor = Mage::getModel('core/email_template_filter');
$html = $processor->filter($this->getData('description'));
return $html;
}
$this->helper('checkout/cart')->getSummaryCount();
or Mage::helper('checkout/cart')->getSummaryCount();
And for the total:Mage::getSingleton('checkout/session')->getQuote()->getSubtotal();
This will display only the total amount for the products.Mage::getSingleton('checkout/session')->getQuote()->getGrandTotal();
{{var order.getCustomerGroupName()}}
you have to create a method in the Order model (overwrite it or edit the core at your own risk).function getCustomerGroupName(){
$group = Mage::getModel('customer/customer_group')->load($this->getCustomerGroupId());
if ($group->getId()){
return $group->getName();
}
return '';//or any default value if the customer is not in a group or is a guest
}