

This tutorial assumes you have already successfully setup a multi domain website.
Today we were confronted with a problem that quite literally left us all stumped. How on earth do we get several domains to use the same secure url. Being not so bright we forgot that sessions and cookies are going to be stored for the one url and that if you transfer directly over to the secure url, you're going to be left without a paddle and each time it redirects to an empty shopping cart.
So to combat this you'll need to create a directory in your root directory that has the same name as the url. http://www.store2.com
Example being
httpdocs is your main directory for your magento installation
httpdocs/store2 is going to be where you will place the following.
A copy of your index.php file with two adjustments. The following needs to be adjusted to look like this;
$mageFilename = '../app/Mage.php';
and at the base of the index.php file place the following (replacing WEBSITE CODE, with the one you configured in the admin)
Mage::run('WEBSITE CODE', 'website');
Also make a copy of your .htaccess file and place that in the folder.
Now go to your web configuration settings. Switch to website 2.
After switching to website to, on the secure base_link_url and set it to {{secure_base_url}}store2/ (store2 being the directory you created)
Thats it, now everything will correctly go to the secure url.
It recently occurred to us that people seem to be very confused by the place order button on the one page checkout, when Paypal is selected as prefered payment method. Normally when checking out with paypal you expect a Proceed to Paypal button to avoid any confusion. Magento already sends an order notification email once you press the place order button so anyone in their right mind could think they have struck gold and that the order has already been accepted without paying. So, here is my new solution that will allow you to change the place order button for a proceed to paypal button, if paypal is selected.
For our example I'll be using the paypal standard method.
Firstly open up your template folder and go to Checkout/Onepage/review.phtml and replace your current checkout button with the following.
<span id="paypal-buttons" class="a-center" style="display:none;">
<input type="image" src="<?php echo $this->getSkinUrl('images/btn_paypal_checkout.gif') ?>" onclick="review.save();" value="<?php echo $this->__('Continue to Paypal') ?>" />
</span>
<span id="review-buttons-container" class="a-center" style="display:block;">
<input type="image" src="<?php echo $this->getSkinUrl('images/btn_place_order.gif') ?>" onclick="review.save();" value="<?php echo $this->__('Place Order') ?>" />
</span> <script language="javascript">
function checkoutbuttons()
{
if (document.getElementById("p_method_paypal_standard").checked == true) {
document.getElementById("paypal-buttons").style.display = "block";
document.getElementById("review-buttons-container").style.display = "none";
}
if (document.getElementById("p_method_paypal_standard").checked == false) {
document.getElementById("paypal-buttons").style.display = "none";
document.getElementById("review-buttons-container").style.display = "block";
}
}
</script> onclick="payment.switchMethod('<?php echo $_code ?>'); checkoutbuttons()"So your tired of always having to go through your catalog to add and remove products that have a special price to a certain category called On Sale or something similar. A solution is on hand now that will allow you to filter out those Special Priced products that have a special from and special to date.
First of all this is the code were that we're going to be using to do this.
<?php
Mage::getSingleton('core/session', array('name' => 'frontend'));
$_productCollection = Mage::getResourceModel('catalogsearch/advanced_collection')
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addMinimalPrice()
->addStoreFilter();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($_productCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($_productCollection);
$todayDate = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d'), date('y'));
$tomorrowDate = date('m/d/y', $tomorrow);
$_productCollection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $tomorrowDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left');
?>
<div class="listing-type-grid catalog-listing">
<?php $_collectionSize = $_productCollection->count() ?>
<?php $i=0; foreach($_productCollection as $_product):?>
<?php if($i++%3==0): ?>
<ol class="grid-row">
<?php endif; ?>
<li class="item">
<p class="product-image">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135); ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
</a>
</p>
<h5><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h5>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->isSaleable()): ?>
<button type="button" class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
<?php else: ?>
<div class="out-of-stock"><?php echo $this->__('Out of stock') ?></div>
<?php endif; ?>
</li>
<?php if($i%3==0 || $i==$_collectionSize): ?>
</ol>
<?php endif; ?>
<?php endforeach ?>
</div>Its only recently that we came across a post which has now brought me a lot of joy to our lives and made it a lot easier on the eyes. Natively dreamweaver does not recognise phtml files and so you end up living in a black and white world, which is ok except you feel like you've been living in a 1950's sid com for the last few years. However help is finally at hand and now you can finally see phtml files for what they really are and we're going to show you how to achieve the same.
First of all since we're all on PC's, the fix described is only for windows based computers. But if you do need a fix for windows you can find the fix here.
Documents and Settings > [user] > Application Data > Adobe Dreamweaver > Configuration > extensions.txt
Change the top line and add the PHTML
HTM,HTML,SHTM,SHTML, ... ,TXT,PHP,PHP3,PHP4,PHP5,PHTML,JSP,WML,TPL, ... ,MASTER:All Documents
And then change the third line down to look like
PHP,PHP3,PHP4,PHP5,TPL,PHTML:PHP Files
Program Files > Adobe > Dreamweaver [Your Version] > configuration > Extensions.txt
Change the top line and add the PHTML
HTM,HTML,SHTM,SHTML, ... ,TXT,PHP,PHP3,PHP4,PHP5,PHTML,JSP,WML,TPL, ... ,MASTER:All Documents
And then change the third line down to look like
PHP,PHP3,PHP4,PHP5,TPL,PHTML:PHP Files
Program Files > Adobe > Dreamweaver [Your Version] > configuration > DocumentTypes > MMDocumentTypes.xml
Go to line 75 and change it so it looks like below
<documenttype id="PHP_MySQL" servermodel="PHP MySQL" internaltype="Dynamic" winfileextension="php,php3,php4,php5,phtml"
macfileextension="php,php3,php4,php5,phtml" file="Default.php" writebyteordermark="false">; </documenttype>
Fin.
Now you can live in the real world and see all your code in colour.
In Magento you have all these great features in terms of adding attributes to your products, but utilising them in a far more constructive way than just "display on product page" is a little bit harder, but worth the learning curve. With some basic php know how you can turn those static stuffy attributes into extremely useful events on the product page. Today we are going to demonstrate a simple, yet effective use of this by showing you how to change an "add to cart" button into a "Pre Order Item" button.
To start with create your attribute in the backend. An example setup would be;
For the dropdown options
Save
Go to Manage Attribute Sets and add pre-order to the various set names.
Now time for the code:
<?php if($_item->isSaleable()): ?>
<?php if ($_product->getData('pre-order')): ?>
<?php $preorder= $_product->getResource()->getAttribute('pre-order')->getFrontend()->getValue($_product); ?>
<?php if ($preorder=="Pre Order Available For This Item"): ?>
<button type="button" class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Pre Order Item') ?></span></button>
<?php else: ?>
<button type="button" class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add To Cart') ?></span></button>
<?php endif; ?>?>
<?php else:
<button type="button" class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add To Cart') ?></span></button>
<?php endif; ?>
<?php endif; ?>
This code can now be used to replace the current add to cart button, from the if saleable statement on both the list.phtml and the view.phtml files in the frontend catalog template folder.
Page 1 of 3