How to Display WordPress blog posts with Featured Images on Magento’s Homepage using FishPig module

How to Display Wordpress blog posts with Featured Images on Magento's Homepage using FishPig module

Hi there, this tutorial assumes you already have FishPig’s magento to wordpress module already installed and configured. Once you have that done open up your homepage theme and type in this code where you want the blog posts to appear

 <?php echo  $this->getLayout()->createBlock('wordpress/sidebar_widget_posts')->setPostCount(6)->setTemplate('wordpress/sidebar/widget/homepost.phtml')->toHtml(); ?>

Next go to your app/design/frontend/yourtheme/yourtheme/wordpress/sidebar/widget/ folder and place in this code:


<?php $posts = $this->getPosts() ?>
<?php if (count($posts) > 0): ?>
			<?php foreach($posts as $post): ?>
					  <?php if ($featuredImage = $post->getFeaturedImage()){ ?>
					    <a href="<?php echo $post->getPermalink() ?>">
					    	 <div class="blog">
					        	<img src="<?php echo $featuredImage->getLargeImage();?>" alt="<?php echo $this->escapeHtml($post->getPostTitle()) ?>"/>
					        </div>
					    </a>
					<?php }  ?>
			<?php endforeach; ?>

<?php endif; ?>

That code will display a blog’s featured image if it has one.

You can also add more too it but using functions like:

$post->getPostTitle(); // Post title
$post->getPostDate(); // Post date
$post->getPostDate(); // Post date

If you want to put more content in the foreach loop.

Finally if you want to display a different image size use these instead:

getFeaturedImage();
getThumbnailImage();
getMediumImage();
getLargeImage();
getFullSizeImage();
getPostThumbnailImage();

Simply choose one and place it instead of getLargeImage in the code posted above.

Finally, the custom featured image code would look like this, you would need to set your custom image size in your wordpress function file, but we assume you did that already. To call up the custom image size you use this code:

getImageByType($type = 'typenamehere');

Magento Show Latest Review on Product Page

Want to show the latest product review on your product page? It is simple add the following

<?php
                $productId = $this->getProduct()->getId(); 
                $reviews = Mage::getModel('review/review')
                    ->getResourceCollection()
                    ->addStoreFilter(Mage::app()->getStore()->getId())
                    ->addEntityFilter('product', $productId)
                    ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                    ->setDateOrder()
                    ->addRateVotes();
                $ratings = array();
                if (count($reviews) > 0) {
                    $x = 1;
                ?>
                    <div class="product-review-template">
                        <h2>Latest Review</h2>
                        <div class="single-review-template">
                            <?php 
                                foreach ($reviews->getItems() as $review) {
                                    echo '<p>'.$review->getDetail().'</p>';
                                    echo '<p><span class="author">'.$review->getNickname().'</span>';
                                    foreach( $review->getRatingVotes() as $vote ) {
                                        echo '<span class="stars">'.$vote->getRatingCode().' - '.$vote->getPercent().'</span></p>';
                                    }
                                    if($x == 1){ break; }
                                }
                            ?>
                        </div>
                    </div>
<?php } ?>

Simple Mobile Menu for Shopify

Do you need to add a mobile menu to your shopify theme? This is a pretty easy process when done correctly. In shopify go to your theme.liquid. In there you will want to look for some code that looks like this (might be slightly different depending on your theme)
[Read more…]

4 Best Canon Lenses for Video for Hobbyists and Beginners

I thought I would right a list of the “Best Canon Lenses for Video” for beginners and hobbyists that don’t have thousands of dollars to spend. Now before you get into my list, if you are a hard core videographer, you might want to leave. I am going to suggest a few lenses that you probably already have, or you have better equipment. This list of for those on a limited budget that are trying to get the most bang for their buck. So without any further ado, here is my list of the 4 Best Canon Lenses for Video.
[Read more…]

Downloading All Images, HTML, CSS, Javascripts and PDFs from SSH

Downloading All Images, HTML, CSS, Javascripts and PDFs from SSH

Need to migrate\back-up a web site that you don’t have access to the core files?  Going through manually by hand is annoying and can take forever.  Here is a simple script to download a majority of the web site files.  It will not download files hosted on CDN’s or other domains, but it is a good starting point.  First login to your linux or unix box. Then type the following command.

Note that if you do this too often, you might get blocked or kicked from a server, so beware of trying to take too much information too fast.

wget -r P . -A jpg,jpeg,gif,png,html,css,txt,php,pdf,js http://www.domainname

Now sit back and watch your machine do the work.

Magento Delete Old Credit Card Numbers – Solved

Magento Delete Old Credit Card Numbers - Solved

Here is a quick tutorial on how to clear credit card numbers. I will include a few scripts that you might helpful. BACKUP YOUR DATABASE. If you don’t back up your database before running these scripts you are playing with fire. So always, back-up before running the scripts.

Magento Clear Credit Cards of Complete and Canceled Orders

Here is a script to clear credit cards for complete or canceled orders. Place this script into a php file on the root level of your magento installation. Wherever you see files like app, skin, var.

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

require_once('app/Mage.php');
Mage::app();

$orders = Mage::getModel('sales/order')->getCollection()
   ->addFieldToFilter('status', array('in' => array('canceled','complete')))
   ->addAttributeToSelect('status')
   ->addAttributeToSelect('increment_id')
   ->addAttributeToSelect('entity_id')
   ->addAttributeToSelect('quote_id')
   ->addAttributeToSelect('created_at');

$prefix=(string)Mage::getConfig()->getTablePrefix(); // Get Prefix

// fetch write database connection that is used in Mage_Core module
$write = Mage::getSingleton('core/resource')->getConnection('core_write');

foreach ($orders as $order) {
    $IncrementId = $order->getIncrementId();
    $OrderStatus = $order->getStatus();
    $EntityId = $order->getEntityId();  // Very Important
    $QuoteId = $order->getQuoteId(); // Very Important
    $year = date('Y', strtotime($order->getCreatedAt()));

           $updatefirsttable = "update ".$prefix."sales_flat_quote_payment set cc_number_enc=null where quote_id=".$QuoteId."";
           $updatesecondtable = "update ".$prefix."sales_flat_order_payment set cc_number_enc=null where entity_id=".$EntityId."";

           $write->query($updatefirsttable);  // Update Quote
           $write->query($updatesecondtable); // Update Order
            echo "Increment ID";
            echo $IncrementId;
            echo ' Quote id: ';
            echo $QuoteId;
            echo ' Entity IdL ';
            echo $EntityId;
            echo ' Year: ';
            echo $year;
            echo '<br/>';

}
echo "complete";

This should go through and remove all of the credit cards for completed and canceled orders. It should also print out to the Increment ID, Quote, Entity ID and Year, this is so you can troubleshoot it if there is an error.

Clearing Pending Credit Cards from Magento by Year

I had a client that needed to clear credit cards for items that were considered PENDING because they never updated them to complete. So I wanted to clear everything before the year 2015. So I just made a few modifications to the script. This clears all pending orders credit cards before the year 2015. You can update it to your year by changing 2015 to whatever year you want.

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

require_once('app/Mage.php');
Mage::app();

$orders = Mage::getModel('sales/order')->getCollection()
   ->addFieldToFilter('status', array('in' => array('pending')))
   ->addAttributeToSelect('status')
   ->addAttributeToSelect('increment_id')
   ->addAttributeToSelect('entity_id')
   ->addAttributeToSelect('quote_id')
   ->addAttributeToSelect('created_at');

$prefix=(string)Mage::getConfig()->getTablePrefix(); // Get Prefix

// fetch write database connection that is used in Mage_Core module
$write = Mage::getSingleton('core/resource')->getConnection('core_write');

foreach ($orders as $order) {
    $IncrementId = $order->getIncrementId();
    $OrderStatus = $order->getStatus();
    $EntityId = $order->getEntityId();  // Very Important
    $QuoteId = $order->getQuoteId(); // Very Important
    $year = date('Y', strtotime($order->getCreatedAt()));

    if ($year < 2015) {

           $updatefirsttable = "update ".$prefix."sales_flat_quote_payment set cc_number_enc=null where quote_id=".$QuoteId."";
           $updatesecondtable = "update ".$prefix."sales_flat_order_payment set cc_number_enc=null where entity_id=".$EntityId."";

           $write->query($updatefirsttable);  // Update Quote
           $write->query($updatesecondtable); // Update Order
            echo "Increment ID";
            echo $IncrementId;
            echo ' Quote id: ';
            echo $QuoteId;
            echo ' Entity IdL ';
            echo $EntityId;
            echo ' Year: ';
            echo $year;
            echo '<br/>';
    }

}
echo "complete";

How To Integrate WordPress Posts on a Magento Site – The Easy Way

How To Integrate Wordpress Posts on a Magento Site - The Easy Way

There are lots of plugins and tutorials out there that try to explain how to integrate WordPress recent blog posts on a Magento site. With all of them you have to either download plugins, establish a wordpress connection, and tweak some Mage code. I have found that if you are just trying to display recent blog posts onto the homepage of your Magento website, there are much easier ways. Just make an snippet that gathers the information from the RSS feed.

I had a client that wanted two display the latest blog post onto the homepage of their Magento site. So I simply went to /app/design/frontend/themename/themename/pages/home.phtml and place in the following code.

<?php
	$channel = new Zend_Feed_Rss('http://example.com/feed');
	$i = 0;
	foreach ($channel as $item):
		if($i < 1) {
			echo '<h5>'.$item->title.'</h5><br/>';
			preg_match_all("/<p>(.*?)<\/p>/si", $item->description, $paragraphs);

			echo $paragraphs[0][0];
			echo $paragraphs[0][1];

			echo "<a href='".$item->link."'' class='readmore'>Read more &gt;&gt;</a>";
			break;
		}
		$i++;
	endforeach;
?>

That’s it, bingo bango. That is a lot easier that trying to make a silly connection.  Just change the Zend_Feed_RSS with your domain name and rss feed location. If you want to show more than one item, then change $i < 1 to whatever number you want.

I hope you find this easier than all the other nonsense.

*As  a note, I made a filter to only display the first to paragraphs.  If you don’t want this you can remove this….

preg_match_all("/<p>(.*?)<\/p>/si", $item->description, $paragraphs);

echo $paragraphs[0][0];
echo $paragraphs[0][1];

and make it this..

echo $item->description

Best Animation Resources
for Learning Animation

Best Animation Resources <br/>for Learning Animation

While I am not a professional Animator, yet, I am a student. But, I believe that like all professions everyone is always learning something new. So I decided to create a list of the “6 best animation resources for learning animation”.  This is a list of resources to help individuals looking to pursue animation as a profession, career, or hobby. These resources are geared towards the art of animation, not the technical, like how to use a software.  I believe you should learn the craft before you learn the software. Some of the resources are books, some of them are web sites, some are free, some cost money. So let’s start my list of the top and best animation resources.  Please feel free to disagree, or comment below, growth is made through sharing resources and ideas!
[Read more…]

Pages: 1 2

Tri.be The Event Calendar Custom Shortcodes

Tri.be The Event Calendar Custom Shortcodes

If you are using Tri.be’s WordPress Event Calendar, sometimes you might want to display event information in a page using a shortcode. Unfortunately the plugin doesn’t have this out of the box, but luckily it is easy enough to add.

First go to your themes function.php file and back-it up.

Second paste in the following code:

add_shortcode('event_code', 'events_shortcode');
function events_shortcode() {

	$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
	$upcoming = new WP_Query();
	$upcoming->query( array(
		'post_type'=> 'tribe_events',
		// 'eventDisplay' => 'past',
		'posts_per_page' => 3,
		'paged' => $paged)
	);
	$return_string = '';
	if ($upcoming->have_posts()) :
		while ($upcoming->have_posts()) :
			$upcoming->the_post();
			$return_string .= '<strong><a href="'.get_permalink().'">'.get_the_title().'</a></strong> <br/>';
			$return_string .= tribe_events_event_schedule_details();
			$return_string .= '<br/><br/>';
		endwhile;
		if ( function_exists('wp_pagenavi') ) wp_pagenavi( array( 'query' => $upcoming ) ); // tell it which query we are paginating
	endif;
	wp_reset_query(); // important to reset the query
	$return_string .= '<a href="'.tribe_get_events_link().'">View All Upcoming Events</a>';
	return $return_string;
}

Next go to the page you would like to add the shortcode. On this page add the following.

[event_code]

Save the page, and now you should see some event information. If you would like to view more or less events on the page edit value in the above code. For example, if you want to change from showing 3 events to 2, go to:

'posts_per_page' => 3,

And change the 3 to 2.

'posts_per_page' => 2,

That is it!

If you have any questions please feel free to contact me through the comments section below. Also be sure to checkout my Visalia Web Design services.

Solve PHP Fatal error: Class ‘Mage_Enterprise_Rma_Block
_Adminhtml_Product_Renderer’

Solve PHP Fatal error: Class 'Mage_Enterprise_Rma_Block<br/>_Adminhtml_Product_Renderer'

Here is how to fix the following magento error after down-grading from enterprise to community.

PHP Fatal error: Class ‘Mage_Enterprise_Rma_Block_Adminhtml_Product_Renderer’ not found in /lib/Varien/Data/Form/Abstract.php on line 146

Login to your mysql and execute the following code:


DELETE FROM eav_attribute WHERE `attribute_code` = 'giftcard_amounts';
DELETE FROM eav_attribute WHERE `attribute_code` = 'related_tgtr_position_limit';
DELETE FROM eav_attribute WHERE `attribute_code` = 'related_tgtr_position_behavior';
DELETE FROM eav_attribute WHERE `attribute_code` = 'upsell_tgtr_position_limit';
DELETE FROM eav_attribute WHERE `attribute_code` = 'upsell_tgtr_position_behavior';
DELETE FROM eav_attribute WHERE source_model LIKE 'enterprise_%';
DELETE FROM eav_attribute WHERE backend_model LIKE 'enterprise_%';
DELETE FROM eav_attribute WHERE attribute_code IN ('gift_wrapping_available', 'gift_wrapping_price');

Bingo bango, problem solved

Answer found on stackoverflow
http://stackoverflow.com/questions/13415426/fatal-error-class-mage-enterprise-rma-block-adminhtml-product-renderer-not-fo