Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2.  
  3. public function getImageUrl($product)
  4. {
  5. $storeId = Mage::app()->getStore()->getId();
  6. $sku = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->geId(), 'sku', $storeId);
  7. $asin = substr($sku,0,10);
  8.  
  9. if ($sku != null) {
  10. $asin = $product->getAsin();
  11. }
  12. return "http://productimages.bundles.com/images/$asin.jpg";
  13. }
  14. else
  15. {
  16. return echo error;
  17. }?>
  18.  
  19. <?php
  20. /**
  21. * @var Bundle_LocalHelpers_Helper_Basic $localHelper
  22. */
  23. $localHelper = Mage::helper('localhelper/basic');
  24. ?>
  25. <div id="owl-demo" class="owl-carousel">
  26. <?php
  27.  
  28. $categoryId = 2; // this is the category holding your products
  29. $products = Mage::getSingleton('catalog/category')->load($categoryId) // load the category
  30. ->getProductCollection() // and the products
  31. ->addAttributeToSelect('image'); // tell Magento which attributes to get
  32.  
  33. foreach ($products as $product) { // iterate through the entire collection
  34. echo '<div class="item"><img src="'.$localHelper->getImageUrl($product);.'"></div>'; // print the image url inside of the required Owl markup
  35. }
  36.  
  37. ?>
  38. </div>
  39.  
  40. <script>
  41. jQuery.noConflict();
  42. jQuery(document).ready(function() {
  43.  
  44. jQuery("#owl-demo").owlCarousel({
  45. items : 4,
  46. lazyLoad : true,
  47. navigation : true
  48. });
  49.  
  50. });
  51. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement