0

I have a custom email template and all seems to be working correctly with the exception of the product sku is not displaying anything.

The code I am using to display the products sku is

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

However it is not displaying anything. If I take the above code and past it on my product detail page (view.phtml) page the products sku gets displayed fine.

My custom email template phtml file is below.

<?php $l = $this->getSamplelistItemsCount() ?>
  <div style="border:1px solid #E0E0E0; padding:15px; background:#F9F9F9;">
<table cellspacing="0" cellpadding="0" border="0" width="650">
   <tr>
        <?php $i = 0; foreach ($this->getSamplelistItems() as $item): $i++ ?>
        <?php /* @var $item Radweb_Samples_Model_Item */ ?>
        <?php /* @var $_product Mage_Catalog_Model_Product */ ?>
        <?php $_product = $item->getProduct(); ?>
        <?php 
            $_product = $item->getProduct();
            $img = $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(135, 135);

            //display simple product image
            if ($_product->getTypeId() == "configurable" && Mage::getStoreConfig('samples/display_config/simple_image', Mage::app()->getStore()->getStoreId())==1) 
            {
               $img = $this->helper('catalog/image')->init(Mage::helper('radweb_samples')->getSimpleProduct($_product), 'thumbnail')->resize(135, 135);
            }

    ?>
    <td width="32%">
        <p align="center" style="font-size:12px;"><a href="<?php echo $this->getProductUrl($_product) ?>"><img src="<?php echo $img; ?>" style="border:1px solid #ccc;" width="135" height="135" alt="" /></a></p>
    </td>
    <td width="32%">
        <p align="center" style="font-size:12px;"><a href="<?php echo $this->getProductUrl($_product) ?>" style="color:#203548;"><strong><?php echo $this->escapeHtml($_product->getName()) ?></strong></a></p>
        <p align="center">Sku: <?php echo $_product->getSku(); ?> or <?php echo $_product->getData('sku'); ?></p>
        <?php if($this->hasDescription($item)): ?><p align="center" style="font-size:12px;"><?php echo $this->__('Comment') ?>:<br /><?php echo $this->getEscapedDescription($item) ?></p><?php endif; ?>


        <div class="product-details">

            <?php if ($_options = $this->getProductOptions($item)):?>
            <div class="truncated">
            <div class="truncated_full_value">
            <dl class="item-options">
                <?php foreach ($_options as $_option) : ?>
                <p align="center"><?php echo $this->htmlEscape($_option['label']) ?>:

                    <?php if (is_array($_option['value'])): ?>
                    <?php echo nl2br(implode("\n", $_option['value'])) ?>
                    <?php else: ?>
                    <?php echo $_option['value'] ?>
                    <?php endif; ?>
                </p>
                <?php endforeach; ?>
            </dl>
            </div>
            </div>
            <?php endif; ?>

        </div>

        <?php
        /*
        <p align="center" style="font-size:12px;"><a href="<?php echo $this->getProductUrl($_product) ?>" style="color:#1E7EC8;"><?php echo $this->__('View Product') ?></a> <small>
        <?php if ($_product->getIsSalable()): ?>|</small> <a href="<?php echo $this->getAddToCartUrl($_product) ?>" style="color:#1E7EC8;"><strong><?php echo $this->__('Add to Cart') ?></strong></a><?php endif;?>
        </p>
        */
        ?>
       </td>
    <?php if ($i%3!=0): ?>
        <td width="2%"></td>
    <?php else: ?>
       </tr>
        <tr>
            <td colspan="5">&nbsp;</td>
        </tr>
        <?php if ($i<$l): ?>
           <tr>
        <?php endif ?>
    <?php endif ?>
<?php endforeach ?>

0

In the backend, go to "manage attributes" and check if "sku" is displayed in product category listings. Set this value to "yes", delete cache and reindex, especially if you use flat catalogs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.