Skip to main content

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url,

Magento

Magneto Note
login/logout
<?php if (! Mage::getSingleton('customer/session')->isLoggedIn()): ?>
<a href="<?php echo Mage::helper('customer')->getLoginUrl(); ?>"><?php echo $this->__('Login') ?></a>
<?php else: ?>
<a href="<?php echo Mage::helper('customer')->getLogoutUrl(); ?>"><?php echo $this->__('Logout') ?></a>
<?php endif; ?>

Add contacts page in static block
<p>{{block type="core/template" name="contactForm" template="contacts/form.phtml"}}</p>

<!– contact form –>
{{block type='core/template' name='contactForm' template='contacts/form.phtml'}}
<!– end of contact form –>

<!--To send the contact form. If you do not include this part, you will see the contact form but when you clic over the send button it didn't work -->
 pero al hacer click sobre enviar no hace nada.-->
<script type="text/javascript">
elem = $('contactForm');
elem.writeAttribute('action', 'contacts/index/post');
</script>

price %
I see that the code in app/code/code/Mage/Catalog/Block/Product/Price.php says:

 $price['savePercent'] = ceil(100 - (( 100/$productPrice ) * $price['price'] ));

 to
  $price['savePercent'] = round(100 - (( 100/$productPrice ) * $price['price'] ));
  www.magentocommerce.com/boards/viewthread/52771/

reset admin password
UPDATE admin_user SET password=CONCAT(MD5('samrat'), ':sG') WHERE username='AdminUsername';

//home page condition
<?php if($this->getIsHomePage()): ?>
/// show in product page condition
<?php if (Mage::app()->getFrontController()->getRequest()->getControllerName() == 'product'): ?>
<?php echo $this->getChildHtml('header_slider_container'); ?>
 <?php endif; ?>
/// show in category page condition
<?php elseif (Mage::app()->getFrontController()->getRequest()->getControllerName() == 'category'): ?>

//change newsleater or other message on submit
MagentoStore\App\Code\Core\Mage\Newsletter\controllers\SubscriberController.php

//remove logo left side
http://www.magentocommerce.com/knowledge-base/entry/turning-on-off-magentos-content-blocks

//best sealer
http://blog.magikcommerce.com/how-to-display-best-selling-products-on-magento-store-home-page/

http://fishpig.co.uk/magento/tutorials/display-categories-and-subcategories-in-magento/
http://www.pauldonnelly.net/magento-display-sale-icon-if-special-price/ //for sell logo

//site of image color change
http://www130.lunapic.com/editor/?action=changecolor

Price Slider

http://www.magentocommerce.com/magento-connect/daffodil-price-slider-8395.html
http://www.magentocommerce.com/magento-connect/catalog/product/view/id/14553/s/magehouse-free-price-slider-9130/
http://www.magentocommerce.com/magento-connect/multiple-select-in-layered-navigation-filters.html

Sidebar Navigation Menu Professional
http://www.magentocommerce.com/magento-connect/sidebar-navigation-menu-professional.html

C:\xampp\htdocs\mg_sample\skin\frontend\default\default\images
//download file

http://freegento.com/ddl-magento-extension.php

//lightbox2
http://connect20.magentocommerce.com/community/IG_LightBox2

//call phtml page in static block
{{block type="catalog/product_list" category_id="4" template="catalog/product/carousel.phtml" }}
//create static block in magento page
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('top_bar')->toHtml(); ?>
//addto cart button
<?if($_product->isSaleable()):?>
            <button class="form-button" onclick="setLocation('<?=$this->getAddToCartUrl($_product)?>')"><span><?=__('Add To Cart')?></span></button>
            <?endif;?>
    ///review rating
        <?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
<?php echo $this->getReviewsSummaryHtml($_product, "short", true)?>
//link to base url
<a href="{{store url=""}}">Link to Base URL</a>
//top menu
<?php echo $this->getChildHtml('topMenu') ?>
    <?php echo $this->getChildHtml('topContainer'); ?>
\\to link
<?php echo $this->getChildHtml('topLinks') ?>
//call phtml page in block
{{block type="newsletter/subscribe" template="newsletter/subscribe.phtml"}}
//call static block in static page
{{block type="cms/block" block_id="slider_right1" template="cms/content.phtml"}}
//how to call a PHTML file within a CMS page Magento
{{block type="core/template" template="catalog/product/form-top.phtml"}}
//call the static block menu  in cms page create
<?php if(Mage::registry('current_product') || Mage::getSingleton('cms/page')->getIdentifier() == 'meditatiekussen'):?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('left_side_bar')->toHtml() ?>
<?php endif; ?>
 To Retrieve URL path in STATIC BLOCK
To get contact us
 <a href="{{store direct_url="contacts"}}">contact us</a>
To get SKIN URL

{{skin url='images/sampleimage.jpg'}}

To get Media URL

{{media url='/sampleimage.jpg'}}

To get Store URL

{{store url='mypage.html'}}

To get Base URL

{{base url='yourstore/mypage.html'}}

TO Retrieve URL path in PHTML
Note: In editing PHTML don't forget to enclode the following code with PHP tag
Not secure Skin URL:

<?php echo $this->getSkinUrl('images/sampleimage.jpg') ?>

Secure Skin URL

<?php echo $this->getSkinUrl('images/ sampleimage.gif', array('_secure'=>true)) ?>

Get  Current URL

$current_url = Mage::helper('core/url')->getCurrentUrl();

Get Home URL

$home_url = Mage::helper('core/url')->getHomeUrl();

Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);


Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

Get Magento Skin Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

Get Magento Store Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Get Magento Js Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);



//get the long description  form category
<?php
$my_product = Mage::getModel('catalog/product')->load($_product->getId());
$newstring = substr($my_product->getDescription(),0,100);
echo $newstring;\
?>

///add menu in amgento
http://www.isummation.com/blog/add-cms-page-links-to-top-navigation-in-magento/




Error - PHP Fatal error: Call to a member function setCustomerId() on a non-object in ... /app/code/core/Mage/Customer/controllers/AccountController.php on line 601

PHP Fatal error:  Call to a member function setCustomerId() on a non-object in ... /app/code/core/Mage/Customer/controllers/AccountController.php on line 601


This occurs when you have upgraded Magento and the theme is not compatible. This is a relatively easy fix. Simply edit app/design/frontend/default/[your_custom_theme_folder]/layout/customer.xml and add the following code direct before the </layout> tag:


<!--
Customer account reset password
-->
   
<customer_account_resetpassword translate="label">
        <label>Reset a Password</label>
        <remove name="right"/>
        <remove name="left"/>
        <reference name="head">
            <action method="setTitle" translate="title" module="customer">
                <title>Reset a Password</title>
            </action>
        </reference>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
            <action method="setHeaderTitle" translate="title" module="customer">
                <title>Reset a Password</title>
            </action>
        </reference>
        <reference name="content">
            <block type="customer/account_resetpassword" name="resetPassword" template="customer/form/resetforgottenpassword.phtml"/>
        </reference>
    </customer_account_resetpassword>
----------------------------------

add faq page in amgento

http://www.blog.magepsycho.com/creating-fancy-faq-page-in-magento-an-easier-approach/


Go to Admin > CMS Pages > Add New Page and implement the following steps:
1. Add FAQ contents
Add the following content in the ‘Content’ > ‘Content’ section of CMS page:

<div class="expand_wrapper">
    <h2 class="expand_heading"><a href="#">1. WordPress Theme Development</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
    <h2 class="expand_heading"><a href="#">2. Magento E-commerce</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
            <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
    <h2 class="expand_heading"><a href="#">3. Website Development</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
            <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
    <h2 class="expand_heading"><a href="#">4. PHP MySql Development</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
            <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
</div>
2. Inject jQuery code
Add the following xml code in ‘Design’ > ‘Layout Update XML’ field of CMS page:
<reference name="head">
    <block type="core/text" name="google.cdn.jquery">
        <action method="setText">
            <text><![CDATA[
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery(".toggle_container").slice(1).hide();//expands first FAQ content
        jQuery(".expand_heading:first").addClass("active");//add active class to first FAQ title
        jQuery("h2.expand_heading").click(function(event){
            event.preventDefault()
            jQuery(this).toggleClass("active");
            jQuery(this).next(".toggle_container").slideToggle("slow");
        });
    });
</script>

            ]]></text>
        </action>
    </block>
</reference>

///////////////////////
//home url
<?php echo  Mage::helper('core/url')->getHomeUrl();?>
//current url
<?php echo Mage::helper('core/url')->getCurrentUrl();?>


create custom menu code in top.phtml file
<div class="nav-container">
<ul id="nav">

<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()):?> active<?php endif;?>"><a href="<?php echo $this->getUrl('')?>"><span><?php echo $this->__('Home') ?></span></a></li>
<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() != Mage::helper('core/url')->getHomeUrl()."faqs/" && Mage::helper('core/url')->getCurrentUrl() != Mage::helper('core/url')->getHomeUrl()."contacts/" && Mage::helper('core/url')->getCurrentUrl() != Mage::helper('core/url')->getHomeUrl()):?> active<?php endif;?>"><a href="" ><span>ELEKTRO MEGASTORE</span></a></li>
<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()."faqs/"):?> active<?php endif;?>"><a href="<?php  echo  $_homeUrl; ?>faqs/" ><span>FAQS</span></a></li>
<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()."contacts/"):?> active<?php endif;?>"><a href="<?php  echo  $_homeUrl; ?>contacts/" ><span>CONTACT</span></a></li>
</ul>
</div>

////////////////////////Add Description //////////////////////////
<?php $_description = $this->getProduct()->getDescription(); ?>
<?php if ($_description): ?>
<div class="category-title"><h2><?php echo $this->__('Details') ?></h2></div>
<div class="border-product">
<div class="std">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?>
</div>
</div>
<?php endif; ?>
/////////////////////end/////////////////////////////////////////

<?php

//getting product object from a looping product
$_product = $this->getProduct();
//getting product object for particular product id
$_product = Mage::getModel('catalog/product')->load(PRODUCT_ID);

echo $_product->getShortDescription(); //product's short description
echo $_product->getDescription(); // product's long description
echo $_product->getName(); //product name
echo $_product->getPrice(); //product's regular Price
echo $_product->getSpecialPrice(); //product's special Price
echo $_product->getProductUrl(); //product url
echo $_product->getImageUrl(); //product's image url
echo $_product->getSmallImageUrl(); //product's small image url
echo $_product->getThumbnailUrl(); //product's thumbnail image url
?>

///////////////////////////////////////Create menu in left side

1.creaate page in cms

chose 2column left
add file

and in the page/2columns-left.phtml write the following code
   <div class="col-left sidebar span3">
<?php if(Mage::registry('current_product') || Mage::getSingleton('cms/page')->getIdentifier() == 'meditatiekussen'):?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('left_side_bar')->toHtml() ?>
<?php endif; ?>
/////////////////////////////////////
//add wish list in customer.xml
<reference name="top.links">
       <action method="addLink" translate="label title" module="wishlist"><label>My Wishlist</label><path>wishlist</path><title>My Wishlist</title><prepare>true</prepare><urlParams/><position>11</position></action>
</reference>
//custom top menu in top.phtml
<div class="nav-container">
<ul id="nav">

<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()):?> active<?php endif;?>"><a href="<?php echo $this->getUrl('')?>"><span><?php echo $this->__('Home') ?></span></a></li>
  <li class="level0 nav-98 parent <?php if (strpos(Mage::helper('core/url')->getCurrentUrl(),'') != false ) :?> active<?php endif;?>">
          <a href="<?php echo $this->getUrl('') . '' ?>"><?php echo $this->__('ELEKTRO MEGASTORE')  ?></a>
    </li>
  <li class="level0 nav-98 parent <?php if (strpos(Mage::helper('core/url')->getCurrentUrl(),'faqs') != false ) :?> active<?php endif;?>">
          <a href="<?php echo $this->getUrl('') . 'faqs' ?>"><?php echo $this->__('FAQS')  ?></a>
    </li>
  <li class="level0 nav-98 parent <?php if (strpos(Mage::helper('core/url')->getCurrentUrl(),'contacts') != false ) :?> active<?php endif;?>">
          <a href="<?php echo $this->getUrl('') . 'contacts' ?>"><?php echo $this->__('CONTACT')  ?></a>
    </li>
</ul>
</div>
Mage::helper('core/url')->getHomeUrl()."hhdhas/";
///top cart
  <div class="cart-top-container">
                            <div class="cart-top">
                     
                                    <span> <?php
$count = $this->helper('checkout/cart')->getSummaryCount();
$total = number_format($this->helper('checkout/cart')->getQuote()->getGrandTotal(),2);
$url = $this->getUrl();
if($count=='')   
{
$count="0";
}
echo "Winkelmand(".$count.")";
//echo $this->__('<a href="'.$url.'checkout/cart">Shopping Cart: <strong> %s </strong></a>',$count);
echo $this->__('<a href="'.$url.'checkout/cart" class="summary"> &euro; %s </a>',$total);
echo $this->__('', $this->helper('core')->formatPrice($total, false));
?>
</span>
                             
                            </div>
                        </div>
///add addtocart button
-----------------

 <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation(' <?php echo $this->helper('checkout/cart')->getAddUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>

 or
 --------------

  <?php if($_product->isSaleable()): ?>
                        <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
----------------
///Add stock in product page

<?php $myString = "Available Inventory!"; ?>
<?php if ((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()<100)
echo $myString;
else (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()
?>
<?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>

However I want either one or the other to display not both: which is what its doing now for an item with less than 100 stock

either this if less than 100 in stock

Available Inventory! 2

or this if stock is over 100,

==================
Top cart
<?php $_cartQty = $this->getSummaryCount() ?>
<?php if ($_cartQty>0): ?>
        <?php if ($_cartQty==1): ?>
            <?php echo $this->__('<a href="%s">U hebt<span class="top-cart-price"> 1  </span><span>producten in uw winkelwagen.</span></a>', $this->getUrl('checkout/cart')) ?>
        <?php else: ?>
            <?php echo $this->__('<a href="%s">U hebt<span class="top-cart-price"> %s  </span><span>producten in uw winkelwagen.</span></a>', $this->getUrl('checkout/cart'), $_cartQty) ?>
        <?php endif ?>
<?php endif ?>
<?php $_items = $this->getRecentItems() ?>
<?php if(count($_items)): ?>
<?php else: ?>
    <span>U hebt geen producten in uw winkelwagen.</span>
<?php endif ?>

.///////////////add social link/////////////
Facebook
1
<a href="http://www.facebook.com/sharer.php?u=<?php echo $_product->getProductUrl() ?>&t=Check+this+out" target="_blank" title="Share this on Facebook" target="_blank"><img src="<?php echo $this->getSkinUrl('') ?>/images/icons/YOUR ICON HERE" alt="Share on Facebook" class="noborder"/></a>
Delicious
1
<a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;"><img class=noborder" src="<?php echo $this->getSkinUrl('') ?>/images/icons/YOUR ICON HERE" alt="Delicious" /> </a>
Google Buzz
1
<a href="http://www.google.com/reader/link?url=<?php echo $_product->getProductUrl() ?>&title=<?php echo $this->htmlEscape($_product->getName()) ?>&srcURL=YOUR URL&srcTitle=YOUR SITE NAME" target="_blank" rel="nofollow external" title="Google Buzz This"><img class="noborder" src="<?php echo $this->getSkinUrl('') ?>/images/icons/YOUR ICON HERE" alt="Google Buzz This!" /></a><!--more-->
Twitter
1
<a title="Send this page on Twitter!" href="http://twitter.com/home?status=Check out the <?php echo $this->htmlEscape($_product->getName()) ?> at <?php echo $_product->getProductUrl() ?> @YOURTWITTERACCOUNT" target="_blank"><img class="noborder" src="<?php echo $this->getSkinUrl('') ?>/images/icons/YOUR ICON HERE" alt="Follow bernos on Twitter"/></a>
////////////////////////////////////////////////
get custo attribute of text field\\\\\\\\\\\\\\\\\\\\\\\fetch on front end
Show Magento Attributes on Frontend

1

If you have created custom magento attributes , then you might need to show them on frontend . So, here is how to call them to your frontend :

If custom attribute which you have created is textarea or textfield then add the following code
?
1
<?php echo $_product->getAttributeName() ?>

for example If I created custom attribute with attribute code published_date then your code will be
?
1
< ?php echo $_product->getPublishedDate() ?>

If custom attribute which you have created is a multiselect or a dropdown then add the following code
?
1
< ?php echo $_product->getAttributeText('published_date') ?>

<?php if ($_product->getAttributeText('bio_option') != "No"): ?>
<p><?php echo $Bio = Mage::getModel('catalog/product')->load($_product->getId())->getWineBio();?></p>
<?php endif; ?>

If you have done all this and still the value is not displaying, then edit the attribute and make sure, you have switched on the option, SHOW ON PRODUCT LISTING.
 How to Obtain Custom Attribute Values in Magento
Posted byDevin R. Olsen on in Magento Tutorials, PHP Tutorials | 27 comments

Today let’s talk about Magento and custom attributes. With Magento you can create as many custom attributes for your products as you like, and there are different attribute types such as:

    Text Field
    Text Area
    Date
    Yes/No
    Multiple Select
    Dropdown
    Price
    Gallery
    Media Image
    Fixed Product Tax

Because there are different types of attributes there are also different ways of obtaining an attributes value. If we were to create a new custom attribute called “theme_color” and the attribute was of a “Text Field” type, we could do something like the following at a product level (meaning a product is loaded) to obtain its value.

<?php
echo $_product->getThemeColor();
?>

$_product is the product of question we have loaded up and ready to work with, and we use “getThemeColor();” because our attribute was named “theme_color”. It’s important to realize that when calling out the value of an attribute with this method, we start with “get” and then capitalize the first letter of each word that is divided by a “_”.

Now this method would give us the value of a simple “Text Field” attribute but what if the attribute was a “Dropdown or a Multiple Select” type? Well if you try to use this “getYourAttributesName()” method on a none “Text Field” or “Textarea” attribute type you will most likely get nothing.

So how do we obtain the value of a “Dropdown or a Multiple Select” attribute type you ask? Well some would argue that you would do so via this method:

<?php
echo $_product->getAttributeText('theme_color');
?>

However, what this would do is return an array of the “Dropdown or Multiple Select” options instead of the value of the selected option you would have set. There is another way to obtain these types of attributes selected value and it looks like this:

<?php
$attributes = $_product->getAttributes();
$themeColor = $attributes['theme_color']->getFrontend()->getValue($_product);
echo $themeColor;
?>

With this method we are simply creating a new variable called “$attributes” and pointing to our “$_product” to then using the “getAttributes()” function to gather all the attributes of this product.

Once we have all the product’s attributes inside of the “$attributes” variable, we make another new variable called “$themeColor”. “$themeColor” then assigns its self to our “$attributes” array that we in turn call out our custom attribute [‘theme_color’].

Once we have pointed to the custom attribute in the “$attributes” array, we simply run through the front end via the function “getFrontend()” and then pull the value down via “getValue($_product)”.

If we then echo our “$themeColor” you should get the value of your custom Drop Down or Multiple Select attribute to do what you will with it.

So to recap:

<?php echo $_product->getThemeColor() ?>

Would get the value of an attribute wholes type is of Text Field or Text Area’s

<?php echo $_product->getAttributeText('theme_color')  ?>

That will not give a value of a Text Field or Text Area attribute type but rather gather an array of all options in a Drop Down or Multiple Select attribute type.

<?php
$attributes = $_product->getAttributes();
$themeColor = $attributes['theme_color']->getFrontend()->getValue($_product);
?>

That will give you the value of any type of attribute, even the value from “Drop Down or Multiple Select” attribute types.

I hope this clears some things up and helps some developers out there .

Thanks!
-------------------------------------------------------------------------------------------

show number of stock on productpage

<?php /* @var $this Mage_Catalog_Block_Product_View_Abstract */?>
<?php $_product = $this->getProduct() ?>

<?php if ($_product->isAvailable()): ?>
    <p class="availability in-stock"><?php echo $this->__('Qty on Hand:') ?> <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; ?>
<?php echo $this->getChildHtml('product_type_data_extra') ?>
<?php echo $this->getPriceHtml($_product) ?>

-----------------------------------------------------------------------------


customer login or not

<?php if ($this->helper('customer')->isLoggedIn()): ?>

<?php if ($_product->isAvailable()): ?>
    <p class="availability in-stock"><?php echo $this->__('Qty on Hand:') ?> <span><!--<?php echo $this->__('In stock') ?>--><?php echo (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; ?>
<?php else: ?>

<?php endif; ?>
----------------------------------------------------
Get the suk
<?php  echo $sku = Mage::getModel('catalog/product')->load($_product->getId())->getSku();  ?>

--------------------------------------------

///remove acount information after loin in left menu hide

The easiest way to remove any link from the My Account panel in Magento is to first copy:

app/design/frontend/base/default/template/customer/account/navigation.phtml

to

app/design/frontend/enterprise/YOURSITE/template/customer/account/navigation.phtml

Open the file and fine this line, it should be around line 34:

<?php $_index = 1; ?>

Right below it add this:

 <?php $_count = count($_links); /* Add or Remove Account Left Navigation Links Here -*/
        unset($_links['tags']); /* My Tags */
        unset($_links['invitations']); /* My Invitations */
        unset($_links['enterprise_customerbalance']); /* Store Credit */
        unset($_links['OAuth Customer Tokens']); /* My Applications */
        unset($_links['enterprise_reward']); /* Reward Points */
        unset($_links['giftregistry']); /* Gift Registry */
        unset($_links['downloadable_products']); /* My Downloadable Products */
        unset($_links['recurring_profiles']); /* Recurring Profiles */
        unset($_links['billing_agreements']); /* Billing Agreements */
        unset($_links['enterprise_giftcardaccount']); /* Gift Card Link */
        ?>
//get category description
 echo Mage::getModel('catalog/layer')->getCurrentCategory()->getDescription();

---------------------------------------

///get prroduct url by sku id
 <?php
           
             $sku = '00004'; // SKU you want to load. 'ecco' is a sku in the Magento demo data

$url =  Mage::getModel('catalog/product')->loadByAttribute('sku',$sku)->getProductUrl();
echo $url;
              ?>
  -------------------------------
  dispaly all sub ctegory
  <?php
$parentCategory     = Mage::registry('current_category');
if($parentCategory){
    $catId              = $parentCategory->getId();
    $category           = Mage::getModel('catalog/category')->load($catId);
    ?>
<div class="block block-layered-nav">
<div class="block-title"><?php echo $category[name]; ?></div>
<div class="block-content">
 <ul>
<?php
   
    $childCategories    = $category->getChildrenCategories();
    foreach($childCategories as $_category){
        //print_r($_category->getData());
       echo "<li><a href='$_category[request_path]'>".$_category[name]."</a></li>";
    }
}
?>
</ul>
</div>
</div>
---------------------
page is category or not

 <?php if(Mage::registry('current_category')):?>

<?php else: ?>
----------------------------------

add new and sale lebel
<div class="product-img-box">
<?php echo $this->getChildHtml('media') ?>
 <?php // SALE label placement
if ( ($_product->getFinalPrice() - $_product->getPrice()) < 0) { ?>
<img class="labels labels-top-right" src="<?php echo $this->getSkinUrl('images/labels/sale.png'); ?>">
<?php } ?>
<?php // NEW label placement
$now = date("Y-m-d");
$newsFrom= substr($_product->getData('news_from_date'),0,10);
$newsTo=  substr($_product->getData('news_to_date'),0,10);
if ($now>=$newsFrom && $now<=$newsTo)
{?> <img class="labels labels-top-left" src="<?php echo $this->getSkinUrl('images/labels/new.png'); ?>"><?};
?>
</div>


or


<?php // SALE label placement
if ( ($_product->getFinalPrice() - $_product->getPrice()) < 0) { ?>
<div class="sale-item"><span>
<?php
$different=$_product->getPrice() - $_product->getFinalPrice();
echo $percent=round($different/$_product->getPrice() * 100);
?>
</span></div>

<?php } ?>
<?php // NEW label placement
$now = date("Y-m-d");
$newsFrom= substr($_product->getData('news_from_date'),0,10);
$newsTo=  substr($_product->getData('news_to_date'),0,10);
if ($now>=$newsFrom && $now<=$newsTo)
{?> <div class="new-item"></div><?};
?>
css


 .new-item {
 background: url("../images/icon-new-product.png") no-repeat scroll left top rgba(0, 0, 0, 0);
    height: 64px;
    left: 6px;
    position: relative;
    top: 10px;
    width: 58px;
    z-index: 999999;
}

.sale-item {
    background: url("../images/icon-sale-product.png") no-repeat scroll left top rgba(0, 0, 0, 0);
    height: 58px;
    position: relative;
    right: -280px;
    top: 68px;
    width: 58px;
    z-index: 999999;
}

.sale-item span {
    color: #FFFFFF;
    float: left;
    font-size: 22px;
    font-weight: bold;
    line-height: 20px;
    margin: 13px 13px 0;
}



/* Labels CSS
-------------------------------------------------------------- */

<style>
.labels { border:none; position:absolute; z-index:99999; position: relative;}
.labels-top-right { top:65px; right:-2px; }
.labels-bottom-right { bottom:-2px; right:-2px; }
.labels-bottom-left { bottom:-2px; left:-2px; }
.labels-top-left { right: -234px; top: 66px; }

</style>


get percentage

<?php
echo $_product->getFinalPrice()."<br>";
echo $_product->getPrice()."<br>";
$different=$_product->getPrice() - $_product->getFinalPrice();
echo $percent=$different/$_product->getPrice() * 100;
echo round($percent);
?>
or
$different=$_product->getPrice() - $_product->getFinalPrice();
echo $percent=round($different/$_product->getPrice() * 100);


----aa-------------------------------------

add phtm file in cms page

{{block type="catalog/product_list" category_id="173" template="catalog/product/featured-products.phtml"}}
-----------------------

http://www.douglasradburn.co.uk/getting-category-thumbnail-images-with-magento/
price %
I see that the code in app/code/code/Mage/Catalog/Block/Product/Price.php says:

 $price['savePercent'] = ceil(100 - (( 100/$productPrice ) * $price['price'] ));

 to
  $price['savePercent'] = round(100 - (( 100/$productPrice ) * $price['price'] ));
  www.magentocommerce.com/boards/viewthread/52771/

reset admin password
UPDATE admin_user SET password=CONCAT(MD5('samrat'), ':sG') WHERE username='AdminUsername';

//home page condition
<?php if($this->getIsHomePage()): ?>
/// show in product page condition
<?php if (Mage::app()->getFrontController()->getRequest()->getControllerName() == 'product'): ?>
<?php echo $this->getChildHtml('header_slider_container'); ?>
 <?php endif; ?>
/// show in category page condition
<?php elseif (Mage::app()->getFrontController()->getRequest()->getControllerName() == 'category'): ?>

//change newsleater or other message on submit
MagentoStore\App\Code\Core\Mage\Newsletter\controllers\SubscriberController.php

//remove logo left side
http://www.magentocommerce.com/knowledge-base/entry/turning-on-off-magentos-content-blocks

//best sealer
http://blog.magikcommerce.com/how-to-display-best-selling-products-on-magento-store-home-page/

http://fishpig.co.uk/magento/tutorials/display-categories-and-subcategories-in-magento/
http://www.pauldonnelly.net/magento-display-sale-icon-if-special-price/ //for sell logo

//site of image color change
http://www130.lunapic.com/editor/?action=changecolor

Price Slider

http://www.magentocommerce.com/magento-connect/daffodil-price-slider-8395.html
http://www.magentocommerce.com/magento-connect/catalog/product/view/id/14553/s/magehouse-free-price-slider-9130/
http://www.magentocommerce.com/magento-connect/multiple-select-in-layered-navigation-filters.html

Sidebar Navigation Menu Professional
http://www.magentocommerce.com/magento-connect/sidebar-navigation-menu-professional.html

C:\xampp\htdocs\mg_sample\skin\frontend\default\default\images
//download file

http://freegento.com/ddl-magento-extension.php

//lightbox2
http://connect20.magentocommerce.com/community/IG_LightBox2

//call phtml page in static block
{{block type="catalog/product_list" category_id="4" template="catalog/product/carousel.phtml" }}
//create static block in magento page
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('top_bar')->toHtml(); ?>
//addto cart button
<?if($_product->isSaleable()):?>
            <button class="form-button" onclick="setLocation('<?=$this->getAddToCartUrl($_product)?>')"><span><?=__('Add To Cart')?></span></button>
            <?endif;?>
    ///review rating
        <?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
<?php echo $this->getReviewsSummaryHtml($_product, "short", true)?>
//link to base url
<a href="{{store url=""}}">Link to Base URL</a>
//top menu
<?php echo $this->getChildHtml('topMenu') ?>
    <?php echo $this->getChildHtml('topContainer'); ?>
\\to link
<?php echo $this->getChildHtml('topLinks') ?>
//call phtml page in block
{{block type="newsletter/subscribe" template="newsletter/subscribe.phtml"}}
//call static block in static page
{{block type="cms/block" block_id="slider_right1" template="cms/content.phtml"}}
//how to call a PHTML file within a CMS page Magento
{{block type="core/template" template="catalog/product/form-top.phtml"}}
//call the static block menu  in cms page create
<?php if(Mage::registry('current_product') || Mage::getSingleton('cms/page')->getIdentifier() == 'meditatiekussen'):?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('left_side_bar')->toHtml() ?>
<?php endif; ?>
 To Retrieve URL path in STATIC BLOCK
To get contact us
 <a href="{{store direct_url="contacts"}}">contact us</a>
To get SKIN URL

{{skin url='images/sampleimage.jpg'}}

To get Media URL

{{media url='/sampleimage.jpg'}}

To get Store URL

{{store url='mypage.html'}}

To get Base URL

{{base url='yourstore/mypage.html'}}

TO Retrieve URL path in PHTML
Note: In editing PHTML don't forget to enclode the following code with PHP tag
Not secure Skin URL:

<?php echo $this->getSkinUrl('images/sampleimage.jpg') ?>

Secure Skin URL

<?php echo $this->getSkinUrl('images/ sampleimage.gif', array('_secure'=>true)) ?>

Get  Current URL

$current_url = Mage::helper('core/url')->getCurrentUrl();

Get Home URL

$home_url = Mage::helper('core/url')->getHomeUrl();

Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);


Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

Get Magento Skin Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

Get Magento Store Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Get Magento Js Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);



//get the long description  form category
<?php
$my_product = Mage::getModel('catalog/product')->load($_product->getId());
$newstring = substr($my_product->getDescription(),0,100);
echo $newstring;\
?>

///add menu in amgento
http://www.isummation.com/blog/add-cms-page-links-to-top-navigation-in-magento/



add faq page in amgento

http://www.blog.magepsycho.com/creating-fancy-faq-page-in-magento-an-easier-approach/


Go to Admin > CMS Pages > Add New Page and implement the following steps:
1. Add FAQ contents
Add the following content in the ‘Content’ > ‘Content’ section of CMS page:

<div class="expand_wrapper">
    <h2 class="expand_heading"><a href="#">1. WordPress Theme Development</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
    <h2 class="expand_heading"><a href="#">2. Magento E-commerce</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
            <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
    <h2 class="expand_heading"><a href="#">3. Website Development</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
            <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
    <h2 class="expand_heading"><a href="#">4. PHP MySql Development</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
            <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
</div>
2. Inject jQuery code
Add the following xml code in ‘Design’ > ‘Layout Update XML’ field of CMS page:
<reference name="head">
    <block type="core/text" name="google.cdn.jquery">
        <action method="setText">
            <text><![CDATA[
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery(".toggle_container").slice(1).hide();//expands first FAQ content
        jQuery(".expand_heading:first").addClass("active");//add active class to first FAQ title
        jQuery("h2.expand_heading").click(function(event){
            event.preventDefault()
            jQuery(this).toggleClass("active");
            jQuery(this).next(".toggle_container").slideToggle("slow");
        });
    });
</script>

            ]]></text>
        </action>
    </block>
</reference>

///////////////////////
//home url
<?php echo  Mage::helper('core/url')->getHomeUrl();?>
//current url
<?php echo Mage::helper('core/url')->getCurrentUrl();?>


create custom menu code in top.phtml file
<div class="nav-container">
<ul id="nav">

<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()):?> active<?php endif;?>"><a href="<?php echo $this->getUrl('')?>"><span><?php echo $this->__('Home') ?></span></a></li>
<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() != Mage::helper('core/url')->getHomeUrl()."faqs/" && Mage::helper('core/url')->getCurrentUrl() != Mage::helper('core/url')->getHomeUrl()."contacts/" && Mage::helper('core/url')->getCurrentUrl() != Mage::helper('core/url')->getHomeUrl()):?> active<?php endif;?>"><a href="" ><span>ELEKTRO MEGASTORE</span></a></li>
<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()."faqs/"):?> active<?php endif;?>"><a href="<?php  echo  $_homeUrl; ?>faqs/" ><span>FAQS</span></a></li>
<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()."contacts/"):?> active<?php endif;?>"><a href="<?php  echo  $_homeUrl; ?>contacts/" ><span>CONTACT</span></a></li>
</ul>
</div>

////////////////////////Add Description //////////////////////////
<?php $_description = $this->getProduct()->getDescription(); ?>
<?php if ($_description): ?>
<div class="category-title"><h2><?php echo $this->__('Details') ?></h2></div>
<div class="border-product">
<div class="std">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?>
</div>
</div>
<?php endif; ?>
/////////////////////end/////////////////////////////////////////

<?php

//getting product object from a looping product
$_product = $this->getProduct();
//getting product object for particular product id
$_product = Mage::getModel('catalog/product')->load(PRODUCT_ID);

echo $_product->getShortDescription(); //product's short description
echo $_product->getDescription(); // product's long description
echo $_product->getName(); //product name
echo $_product->getPrice(); //product's regular Price
echo $_product->getSpecialPrice(); //product's special Price
echo $_product->getProductUrl(); //product url
echo $_product->getImageUrl(); //product's image url
echo $_product->getSmallImageUrl(); //product's small image url
echo $_product->getThumbnailUrl(); //product's thumbnail image url
?>

///////////////////////////////////////Create menu in left side

1.creaate page in cms

chose 2column left
add file

and in the page/2columns-left.phtml write the following code
   <div class="col-left sidebar span3">
<?php if(Mage::registry('current_product') || Mage::getSingleton('cms/page')->getIdentifier() == 'meditatiekussen'):?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('left_side_bar')->toHtml() ?>
<?php endif; ?>
/////////////////////////////////////
//add wish list in customer.xml
<reference name="top.links">
       <action method="addLink" translate="label title" module="wishlist"><label>My Wishlist</label><path>wishlist</path><title>My Wishlist</title><prepare>true</prepare><urlParams/><position>11</position></action>
</reference>
//custom top menu in top.phtml
<div class="nav-container">
<ul id="nav">

<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()):?> active<?php endif;?>"><a href="<?php echo $this->getUrl('')?>"><span><?php echo $this->__('Home') ?></span></a></li>
  <li class="level0 nav-98 parent <?php if (strpos(Mage::helper('core/url')->getCurrentUrl(),'') != false ) :?> active<?php endif;?>">
          <a href="<?php echo $this->getUrl('') . '' ?>"><?php echo $this->__('ELEKTRO MEGASTORE')  ?></a>
    </li>
  <li class="level0 nav-98 parent <?php if (strpos(Mage::helper('core/url')->getCurrentUrl(),'faqs') != false ) :?> active<?php endif;?>">
          <a href="<?php echo $this->getUrl('') . 'faqs' ?>"><?php echo $this->__('FAQS')  ?></a>
    </li>
  <li class="level0 nav-98 parent <?php if (strpos(Mage::helper('core/url')->getCurrentUrl(),'contacts') != false ) :?> active<?php endif;?>">
          <a href="<?php echo $this->getUrl('') . 'contacts' ?>"><?php echo $this->__('CONTACT')  ?></a>
    </li>
</ul>
</div>
Mage::helper('core/url')->getHomeUrl()."hhdhas/";
///top cart
  <div class="cart-top-container">
                            <div class="cart-top">
                     
                                    <span> <?php
$count = $this->helper('checkout/cart')->getSummaryCount();
$total = number_format($this->helper('checkout/cart')->getQuote()->getGrandTotal(),2);
$url = $this->getUrl();
if($count=='')   
{
$count="0";
}
echo "Winkelmand(".$count.")";
//echo $this->__('<a href="'.$url.'checkout/cart">Shopping Cart: <strong> %s </strong></a>',$count);
echo $this->__('<a href="'.$url.'checkout/cart" class="summary"> &euro; %s </a>',$total);
echo $this->__('', $this->helper('core')->formatPrice($total, false));
?>
</span>
                             
                            </div>
                        </div>
///add addtocart button
-----------------

 <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation(' <?php echo $this->helper('checkout/cart')->getAddUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>

 or
 --------------

  <?php if($_product->isSaleable()): ?>
                        <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
----------------
///Add stock in product page

<?php $myString = "Available Inventory!"; ?>
<?php if ((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()<100)
echo $myString;
else (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()
?>
<?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>

However I want either one or the other to display not both: which is what its doing now for an item with less than 100 stock

either this if less than 100 in stock

Available Inventory! 2

or this if stock is over 100,

==================
Top cart
<?php $_cartQty = $this->getSummaryCount() ?>
<?php if ($_cartQty>0): ?>
        <?php if ($_cartQty==1): ?>
            <?php echo $this->__('<a href="%s">U hebt<span class="top-cart-price"> 1  </span><span>producten in uw winkelwagen.</span></a>', $this->getUrl('checkout/cart')) ?>
        <?php else: ?>
            <?php echo $this->__('<a href="%s">U hebt<span class="top-cart-price"> %s  </span><span>producten in uw winkelwagen.</span></a>', $this->getUrl('checkout/cart'), $_cartQty) ?>
        <?php endif ?>
<?php endif ?>
<?php $_items = $this->getRecentItems() ?>
<?php if(count($_items)): ?>
<?php else: ?>
    <span>U hebt geen producten in uw winkelwagen.</span>
<?php endif ?>

.///////////////add social link/////////////
Facebook
1
<a href="http://www.facebook.com/sharer.php?u=<?php echo $_product->getProductUrl() ?>&t=Check+this+out" target="_blank" title="Share this on Facebook" target="_blank"><img src="<?php echo $this->getSkinUrl('') ?>/images/icons/YOUR ICON HERE" alt="Share on Facebook" class="noborder"/></a>
Delicious
1
<a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;"><img class=noborder" src="<?php echo $this->getSkinUrl('') ?>/images/icons/YOUR ICON HERE" alt="Delicious" /> </a>
Google Buzz
1
<a href="http://www.google.com/reader/link?url=<?php echo $_product->getProductUrl() ?>&title=<?php echo $this->htmlEscape($_product->getName()) ?>&srcURL=YOUR URL&srcTitle=YOUR SITE NAME" target="_blank" rel="nofollow external" title="Google Buzz This"><img class="noborder" src="<?php echo $this->getSkinUrl('') ?>/images/icons/YOUR ICON HERE" alt="Google Buzz This!" /></a><!--more-->
Twitter
1
<a title="Send this page on Twitter!" href="http://twitter.com/home?status=Check out the <?php echo $this->htmlEscape($_product->getName()) ?> at <?php echo $_product->getProductUrl() ?> @YOURTWITTERACCOUNT" target="_blank"><img class="noborder" src="<?php echo $this->getSkinUrl('') ?>/images/icons/YOUR ICON HERE" alt="Follow bernos on Twitter"/></a>
////////////////////////////////////////////////
get custo attribute of text field\\\\\\\\\\\\\\\\\\\\\\\fetch on front end
Show Magento Attributes on Frontend

1

If you have created custom magento attributes , then you might need to show them on frontend . So, here is how to call them to your frontend :

If custom attribute which you have created is textarea or textfield then add the following code
?
1
<?php echo $_product->getAttributeName() ?>

for example If I created custom attribute with attribute code published_date then your code will be
?
1
< ?php echo $_product->getPublishedDate() ?>

If custom attribute which you have created is a multiselect or a dropdown then add the following code
?
1
< ?php echo $_product->getAttributeText('published_date') ?>

<?php if ($_product->getAttributeText('bio_option') != "No"): ?>
<p><?php echo $Bio = Mage::getModel('catalog/product')->load($_product->getId())->getWineBio();?></p>
<?php endif; ?>

If you have done all this and still the value is not displaying, then edit the attribute and make sure, you have switched on the option, SHOW ON PRODUCT LISTING.
 How to Obtain Custom Attribute Values in Magento
Posted byDevin R. Olsen on in Magento Tutorials, PHP Tutorials | 27 comments

Today let’s talk about Magento and custom attributes. With Magento you can create as many custom attributes for your products as you like, and there are different attribute types such as:

    Text Field
    Text Area
    Date
    Yes/No
    Multiple Select
    Dropdown
    Price
    Gallery
    Media Image
    Fixed Product Tax

Because there are different types of attributes there are also different ways of obtaining an attributes value. If we were to create a new custom attribute called “theme_color” and the attribute was of a “Text Field” type, we could do something like the following at a product level (meaning a product is loaded) to obtain its value.

<?php
echo $_product->getThemeColor();
?>

$_product is the product of question we have loaded up and ready to work with, and we use “getThemeColor();” because our attribute was named “theme_color”. It’s important to realize that when calling out the value of an attribute with this method, we start with “get” and then capitalize the first letter of each word that is divided by a “_”.

Now this method would give us the value of a simple “Text Field” attribute but what if the attribute was a “Dropdown or a Multiple Select” type? Well if you try to use this “getYourAttributesName()” method on a none “Text Field” or “Textarea” attribute type you will most likely get nothing.

So how do we obtain the value of a “Dropdown or a Multiple Select” attribute type you ask? Well some would argue that you would do so via this method:

<?php
echo $_product->getAttributeText('theme_color');
?>

However, what this would do is return an array of the “Dropdown or Multiple Select” options instead of the value of the selected option you would have set. There is another way to obtain these types of attributes selected value and it looks like this:

<?php
$attributes = $_product->getAttributes();
$themeColor = $attributes['theme_color']->getFrontend()->getValue($_product);
echo $themeColor;
?>

With this method we are simply creating a new variable called “$attributes” and pointing to our “$_product” to then using the “getAttributes()” function to gather all the attributes of this product.

Once we have all the product’s attributes inside of the “$attributes” variable, we make another new variable called “$themeColor”. “$themeColor” then assigns its self to our “$attributes” array that we in turn call out our custom attribute [‘theme_color’].

Once we have pointed to the custom attribute in the “$attributes” array, we simply run through the front end via the function “getFrontend()” and then pull the value down via “getValue($_product)”.

If we then echo our “$themeColor” you should get the value of your custom Drop Down or Multiple Select attribute to do what you will with it.

So to recap:

<?php echo $_product->getThemeColor() ?>

Would get the value of an attribute wholes type is of Text Field or Text Area’s

<?php echo $_product->getAttributeText('theme_color')  ?>

That will not give a value of a Text Field or Text Area attribute type but rather gather an array of all options in a Drop Down or Multiple Select attribute type.

<?php
$attributes = $_product->getAttributes();
$themeColor = $attributes['theme_color']->getFrontend()->getValue($_product);
?>

That will give you the value of any type of attribute, even the value from “Drop Down or Multiple Select” attribute types.

I hope this clears some things up and helps some developers out there .

Thanks!
-------------------------------------------------------------------------------------------

show number of stock on productpage

<?php /* @var $this Mage_Catalog_Block_Product_View_Abstract */?>
<?php $_product = $this->getProduct() ?>

<?php if ($_product->isAvailable()): ?>
    <p class="availability in-stock"><?php echo $this->__('Qty on Hand:') ?> <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; ?>
<?php echo $this->getChildHtml('product_type_data_extra') ?>
<?php echo $this->getPriceHtml($_product) ?>

-----------------------------------------------------------------------------


customer login or not

<?php if ($this->helper('customer')->isLoggedIn()): ?>

<?php if ($_product->isAvailable()): ?>
    <p class="availability in-stock"><?php echo $this->__('Qty on Hand:') ?> <span><!--<?php echo $this->__('In stock') ?>--><?php echo (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; ?>
<?php else: ?>

<?php endif; ?>
----------------------------------------------------
Get the suk
<?php  echo $sku = Mage::getModel('catalog/product')->load($_product->getId())->getSku();  ?>

--------------------------------------------

///remove acount information after loin in left menu hide

The easiest way to remove any link from the My Account panel in Magento is to first copy:

app/design/frontend/base/default/template/customer/account/navigation.phtml

to

app/design/frontend/enterprise/YOURSITE/template/customer/account/navigation.phtml

Open the file and fine this line, it should be around line 34:

<?php $_index = 1; ?>

Right below it add this:

 <?php $_count = count($_links); /* Add or Remove Account Left Navigation Links Here -*/
        unset($_links['tags']); /* My Tags */
        unset($_links['invitations']); /* My Invitations */
        unset($_links['enterprise_customerbalance']); /* Store Credit */
        unset($_links['OAuth Customer Tokens']); /* My Applications */
        unset($_links['enterprise_reward']); /* Reward Points */
        unset($_links['giftregistry']); /* Gift Registry */
        unset($_links['downloadable_products']); /* My Downloadable Products */
        unset($_links['recurring_profiles']); /* Recurring Profiles */
        unset($_links['billing_agreements']); /* Billing Agreements */
        unset($_links['enterprise_giftcardaccount']); /* Gift Card Link */
        ?>
//get category description
 echo Mage::getModel('catalog/layer')->getCurrentCategory()->getDescription();

---------------------------------------

///get prroduct url by sku id
 <?php
           
             $sku = '00004'; // SKU you want to load. 'ecco' is a sku in the Magento demo data

$url =  Mage::getModel('catalog/product')->loadByAttribute('sku',$sku)->getProductUrl();
echo $url;
              ?>
  -------------------------------
  dispaly all sub ctegory
  <?php
$parentCategory     = Mage::registry('current_category');
if($parentCategory){
    $catId              = $parentCategory->getId();
    $category           = Mage::getModel('catalog/category')->load($catId);
    ?>
<div class="block block-layered-nav">
<div class="block-title"><?php echo $category[name]; ?></div>
<div class="block-content">
 <ul>
<?php
   
    $childCategories    = $category->getChildrenCategories();
    foreach($childCategories as $_category){
        //print_r($_category->getData());
       echo "<li><a href='$_category[request_path]'>".$_category[name]."</a></li>";
    }
}
?>
</ul>
</div>
</div>
---------------------
page is category or not

 <?php if(Mage::registry('current_category')):?>

<?php else: ?>
----------------------------------

add new and sale lebel
<div class="product-img-box">
<?php echo $this->getChildHtml('media') ?>
 <?php // SALE label placement
if ( ($_product->getFinalPrice() - $_product->getPrice()) < 0) { ?>
<img class="labels labels-top-right" src="<?php echo $this->getSkinUrl('images/labels/sale.png'); ?>">
<?php } ?>
<?php // NEW label placement
$now = date("Y-m-d");
$newsFrom= substr($_product->getData('news_from_date'),0,10);
$newsTo=  substr($_product->getData('news_to_date'),0,10);
if ($now>=$newsFrom && $now<=$newsTo)
{?> <img class="labels labels-top-left" src="<?php echo $this->getSkinUrl('images/labels/new.png'); ?>"><?};
?>
</div>


or


<?php // SALE label placement
if ( ($_product->getFinalPrice() - $_product->getPrice()) < 0) { ?>
<div class="sale-item"><span>
<?php
$different=$_product->getPrice() - $_product->getFinalPrice();
echo $percent=round($different/$_product->getPrice() * 100);
?>
</span></div>

<?php } ?>
<?php // NEW label placement
$now = date("Y-m-d");
$newsFrom= substr($_product->getData('news_from_date'),0,10);
$newsTo=  substr($_product->getData('news_to_date'),0,10);
if ($now>=$newsFrom && $now<=$newsTo)
{?> <div class="new-item"></div><?};
?>
css


 .new-item {
 background: url("../images/icon-new-product.png") no-repeat scroll left top rgba(0, 0, 0, 0);
    height: 64px;
    left: 6px;
    position: relative;
    top: 10px;
    width: 58px;
    z-index: 999999;
}

.sale-item {
    background: url("../images/icon-sale-product.png") no-repeat scroll left top rgba(0, 0, 0, 0);
    height: 58px;
    position: relative;
    right: -280px;
    top: 68px;
    width: 58px;
    z-index: 999999;
}

.sale-item span {
    color: #FFFFFF;
    float: left;
    font-size: 22px;
    font-weight: bold;
    line-height: 20px;
    margin: 13px 13px 0;
}



/* Labels CSS
-------------------------------------------------------------- */

<style>
.labels { border:none; position:absolute; z-index:99999; position: relative;}
.labels-top-right { top:65px; right:-2px; }
.labels-bottom-right { bottom:-2px; right:-2px; }
.labels-bottom-left { bottom:-2px; left:-2px; }
.labels-top-left { right: -234px; top: 66px; }

</style>


get percentage

<?php
echo $_product->getFinalPrice()."<br>";
echo $_product->getPrice()."<br>";
$different=$_product->getPrice() - $_product->getFinalPrice();
echo $percent=$different/$_product->getPrice() * 100;
echo round($percent);
?>
or
$different=$_product->getPrice() - $_product->getFinalPrice();
echo $percent=round($different/$_product->getPrice() * 100);


----aa-------------------------------------

add phtm file in cms page

{{block type="catalog/product_list" category_id="173" template="catalog/product/featured-products.phtml"}}
-----------------------

http://www.douglasradburn.co.uk/getting-category-thumbnail-images-with-magento/

Comments

Popular posts from this blog

Create post with all post type

<?php /* add_action( 'wp_enqueue_scripts', 'mpcth_child_enqueue_scripts', 1000 ); function mpcth_child_enqueue_scripts() { wp_enqueue_style( 'mpc-styles-child', get_stylesheet_directory_uri() . '/style_custom.css' ); } */ function registration_form( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) { ?>     <style>       /* Always set the map height explicitly to define the size of the div        * element that contains the map. */     #map {     height: 260px; }     </style>   <script> function initMap() {     var map = new google.maps.Map(document.getElementById('map'), {       center: {lat: -33.8688, lng: 151.2195},       zoom: 13     });     var input = document.getElementById('searchInput');    // map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);    

Create Signature pad with save on database in php

Create Signature pad with save on database in php 1.create a folder images index.php ============   <!DOCTYPE >     <head>     <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />     <title>Signature Pad</title>     <script type="text/javascript" src="jquery-1.8.0.min.js"></script>     <script type="text/javascript"> $(document).ready(function () {     /** Set Canvas Size **/     var canvasWidth = 400;     var canvasHeight = 100;     /** IE SUPPORT **/     var canvasDiv = document.getElementById('signaturePad');     canvas = document.createElement('canvas');     canvas.setAttribute('width', canvasWidth);     canvas.setAttribute('height', canvasHeight);     canvas.setAttribute('id', 'canvas');     canvasDiv.appendChild(canvas);     if (typeof G_vmlCanvasManager != 'undefined') {        

WooCommerce Mini cart With Ajax

WooCommerce Mini cart //MINI CART SECTION   <div class="productdiv rightcart">                                                         <?php if ( ! WC()->cart->is_empty() ) : ?>     <ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">         <?php             do_action( 'woocommerce_before_mini_cart_contents' );             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {                 $_product     = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );                 $product_id   = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );                 if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_c