Categories
Uncategorized

How to get more detailed logs for errors in magento

If your getting this error:

 ERR (3): Warning: simplexml_load_string() 

It dosent actually give you very many details but – if you add a line of code to a file you can get a more detailed error.

Open: /lib/Varien/Simplexml/Config.php and go to line 510:

You will see this:

$xml = simplexml_load_string($string, $this->_elementClass);

add this under that line:

if(!$xml){ Mage::log($string); } 
Categories
Uncategorized

Magento Multi Domain Separate Robots.txt Files

If you have more than one domain running on one magento platform You may need to run separate robot.txt files. Just add these rewrite conditions into your .htaccess file

############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

RewriteCond %{HTTP_HOST} siteone\.com$ 
RewriteRule ^robots\.txt$ /siteone.txt [L] 
 
RewriteCond %{HTTP_HOST} sitetwo\.com$ 
RewriteRule ^robots\.txt$ /sitetwo.txt [L]

############################################

Then just add your robot.txt information in those text files and your done! Test it though a online tester.

Categories
Uncategorized

Magento 1 how to secure your server

Anyone who has been the owner of a eCommerce store knows that if you don’t take precautions getting hacked is a matter of when not if. In addition to any other steps you can find online here are a few more I have been doing lately.

We do offer hosting here at Towering Media and we have already taken these steps.

• Run a PCI complaint server.
• Stop listening to the FTP port on the computer. Instead connect over SFTP though the SSH port.
• Randomized your SSH port.
• Run CFS firewall
• Stop listening on your web disk port usually 2077
• Setup brute force protection
• Update your openSSL version
updating your OPENSSL through SSH

wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
  tar -xvzf openssl-1.0.1j.tar.gz
  cd openssl-1.0.1j
  ./config --prefix=/usr/
  make
  sudo make install

• Of course keep your magento installation updated
• Keep your blog software, forums, ticket systems etc. up to date.
Create a development site for WHM/Cpanel users make the development site in another cpanel account. Put a .htaccess password protection file on it. This way if you need to give our your FTP / Cpanel logins to third party developers that may be overseas they don’t have access to your live site. Ask them what files they made changes to and move those files to live yourself / or your trusted developer can do this.

Categories
Uncategorized

How to add custom english verbiage for price label for specific customer group in magento

This is the php if statement that you would add to your view.php file for changing out the english verbiage that pulls the price label for a specific customer group, like wholesale as this rule is for. You would find this in your view.php file for the product page

<span class="price-label"><?php echo $_specialPriceStoreLabel</span>

and change it to this:

 <span class="price-label">
					
					
<?php $_isLoggedIn = $this->helper('customer')->isLoggedIn(); ?>

<?php $_myGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
    if($_myGroupId == 2){
?>
  Wholesale Price
 <?php 
    }
    else
    {
    ?>
       <?php echo $_specialPriceStoreLabel ?><?php } ?></span>
Categories
Uncategorized

How to display the SKU on the frontend product page in magento

Catalog > Attributes > Manage Attributes > […search for sku…]
Scroll down to Frontend Properties > Visible on Product View Page on Front-end > Yes > Save

And thats it, just refresh your cache and your good to go.

Categories
Uncategorized

How to display the quantity of products in stock on the Magento 1 front end product page

This is how you enable the display of the quantity of products in inventory on the front end product page.

Open /app/design/frontend/default/YOURTHEME/template/catalog/product/view.phtml

In there you can paste this code anywhere you would like the stock quantity to display:

<?php if ($_product->isAvailable()): ?>
    <p class="availability in-stock"><?php echo $this->__('Qty Available:') ?> <span><!--<?php echo $this->__('In stock') ?>--><?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?></span></p>
<?php else: ?>
    <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
Categories
Uncategorized

Magento category with products that have stock greater than 0

We had to modify the code we used for this Magento category with all products except out of stock products

Change this part

$inStockProductIds = array();

$inStockCollection = Mage::getModel(‘cataloginventory/stock’)
->getItemCollection()
->addFieldToFilter(‘is_in_stock’,
array( ‘eq’ => 1 )
)

To this

$inStockCollection = Mage::getModel('cataloginventory/stock')
    ->getItemCollection()
->addQtyFilter('>', 0)
Categories
Uncategorized

How to call a PHTML file from a CMS block in Magento

This is how you call a PHTML file from a CMS block in magento.

{{block type="core/template" template="catalog/product/form-top.phtml"}}