I already work on a carousel in category for product push_ahead. On the carousel i want to display share button. But it's still not work and i doesn't want to use any module for that.

In a second way i wanted to know how can i short the link for example on twitter with bitly ? Without using any module ?

So here my code :

$_helper = $this->helper('catalog/output');
if (!is_null($this->getProductCollection())) {

    <div class="owl-carousel owl-theme" id="carousel_favorite">
        $i = 0;
        foreach ($this->getProductCollection() as $product):
            <?php if ($product->isSaleable()) { ?>
                <div class="item">

                    <?php $_imgSize = 278; ?>
                    <div class="product-image">
                        <div class="selection">Coup de cœur #</div>
                        <a href="<?php echo $product->getProductUrl() ?>" >
                            <img class="gondole" id="product-collection-image-<?php echo $product->getId(); ?>"
                                 src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize($_imgSize); ?>"
                                 alt="<?php echo $this->stripTags($this->getImageLabel($product, 'small_image'), null, true) ?>" width="<?php echo $_imgSize; ?>" />                        </a>
                    <div class="product-info">
                        echo $this->getChild('favorite_carousel_price')->getPriceHtml($product);
                        <div class="social"><span><span class="icon icon-sharing"></span></span>
                            <br />
                            <ul class="sharing-links">
                                <?php  $_productName = urlencode(trim($_helper->productAttribute($product, $product->getName(), 'name'))) ?>
                                <?php  $_productImageUrl = urlencode(trim($this->helper('catalog/image')->init($product, 'image'))) ?>
                                <?php $_productUrl = urlencode(trim($product->getProductUrl())) ?>
                                    <?php $_u = 'p[url]=' . $_productUrl . '&p[images][0]=' . $_productImageUrl . '&p[title]=' . $_productName . '&p[summary]=' . urlencode(trim($_helper->productAttribute($_product, nl2br($product->getShortDescription()), 'short_description'))); ?>
                                    <a href="<?php echo 'http://www.facebook.com/sharer.php?s=100&' . $_u; ?>" target="_blank" title="<?php echo $this->__('Share on Facebook') ?>" class="link-facebook">
                                        <?php echo $this->__('Share Facebook') ?>
                                    <a href="<?php echo 'http://twitter.com/home?status=' . $_productName . '+' . $_productUrl; ?>" target="_blank" title="<?php echo $this->__('Share on Twitter') ?>" class="link-twitter"><?php echo $this->__('Share on Twitter') ?></a>
                                    <a href="<?php echo 'https://pinterest.com/pin/create/button/?url=' . $_productUrl . '&media=' . $_productImageUrl . '&description=' . $_productName; ?>" target="_blank" title="<?php echo $this->__('Share on Pinterest') ?>" class="link-pinterest"><?php echo $this->__('Share on Pinterest') ?></a>
                                    <a href="<?php echo 'https://plus.google.com/share?url=' . $_productUrl; ?>" target="_blank" title="<?php echo $this->__('Share on Google+') ?>" class="link-googleplus"><?php echo $this->__('Share on Google+') ?></a>


            <?php } ?>
        <?php endforeach; ?>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="<?php echo $this->getSkinUrl('owlcarousel/js/owl.carousel.min.js'); ?>"></script>
    <script type="text/javascript">
        var toto = jQuery.noConflict();
        toto(window).load(function () {
            toto('#carousel_favorite').owlCarousel({autoPlay: true, navigation: true, slideSpeed: 300, paginationSpeed: 400, singleItem: true});

Please use small_image instead of image because if you enable flat setting for product then you did not get image as magento defaultly not save image in catalog_product_STOREID.

$this->helper('catalog/image')->init($product, 'image')


$this->helper('catalog/image')->init($product, 'small_image')

Also donot use cache image for share because if you clear image cache then this image will varnish from cache

| improve this answer | |

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.