コード例 #1
0
 /**	=============================
     *
     * Get all required data for a product layout
     *
     * @product_model obj Magento product model
     * @args array WP shortcode atts
     * @return array
     *
     ============================= */
 public function get_product_data($product_model, $args)
 {
     $product_block = new Mage_Catalog_Block_Product();
     $product_data = array();
     $product_data['name'] = trim($product_model->getName());
     $product_data['url'] = $product_model->getProductUrl();
     $product_data['images'] = false;
     $product_data['description'] = false;
     $product_data['price'] = false;
     $product_data['add_url'] = false;
     $product_data['saleable'] = $product_model->isSaleable();
     $product_data['in_stock'] = $product_model->getIsInStock();
     if ($args['img']) {
         $product_data['images'] = array('thumb1x' => Mage::helper('catalog/image')->init($product_model, 'thumbnail')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize((int) $args['img_width'])->__toString(), 'thumb2x' => Mage::helper('catalog/image')->init($product_model, 'thumbnail')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize((int) $args['img_width'] * 2)->__toString());
     }
     if ($args['desc']) {
         // get and trim description
         $desc = trim($product_model->getShortDescription());
         // remove first and last p tags
         $desc = preg_replace('/<p[^>]*>(.*)<\\/p[^>]*>/i', '$1', $desc);
         // replace p tags with br br
         $desc = str_replace(array('<p>', '</p>'), array('', '<br /><br />'), $desc);
         $product_data['description'] = $desc;
     }
     if ($args['price']) {
         $product_data['price'] = preg_replace('/\\s+/', ' ', $product_block->getPriceHtml($product_model, true));
     }
     if ($args['type'] == "add") {
         $product_data['add_url'] = Mage::helper('checkout/cart')->getAddUrl($product_model);
     }
     return $product_data;
 }
コード例 #2
0
ファイル: Product.php プロジェクト: ramantalkin/tmp01skin
 protected function _toHtml()
 {
     if ($this->getProduct()) {
         return parent::_toHtml();
     }
     return '';
 }
コード例 #3
0
ファイル: Product.php プロジェクト: jokusafet/MagentoSource
 public function __construct()
 {
     parent::__construct();
     if (!Mage::registry('product') && $this->getProductId()) {
         $product = Mage::getModel('catalog/product')->load($this->getProductId());
         Mage::register('product', $product);
     }
     $this->_product = $product = Mage::registry('product');
     if ($sticker = $product->getCmProductStickers()) {
         $this->_sticker = Mage::getModel('stickers/stickers')->loadByIdentifier($sticker);
     }
 }
コード例 #4
0
 protected function _toHtml()
 {
     return parent::_toHtml();
 }
コード例 #5
0
ファイル: Widget.php プロジェクト: ramantalkin/tmp01skin
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     $this->getCollection()->load();
     return $this;
 }
コード例 #6
0
ファイル: Navigation.php プロジェクト: neelimakedia/renowala
 public function htmlshownumberproduct($category, $id, $number, $level)
 {
     $idc = $category->parent_id;
     $widthp = $this->widthp($idc);
     $widthchildren = $this->width($idc);
     $widthc = Mage::helper('megamenu')->Megamenu($id);
     if ($widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_left'] == 1) {
         $left = ($widthc[0]['width_block_left'] + 10) / $widthchildren * 100;
     } else {
         if ($widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_right'] == 1) {
             $left = ($widthc[0]['width_block_right'] + 10) / $widthchildren * 100;
         }
     }
     $w = floor($widthp - $left);
     $widthchildrenc = $w * $widthchildren / 100;
     $_productCollection = Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('status', 1)->addAttributeToFilter('visibility', array('neq' => 1))->addAttributeToSelect('*')->addCategoryFilter(Mage::getModel('catalog/category')->load($id));
     $html = '';
     if ($widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_left'] == 1 || $widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_right'] == 1 && $level != 0) {
         $html .= '<ul class="level1 menu-product' . $level . ' menu-product-one" style="width:' . $widthchildrenc . 'px;">';
     } else {
         $html .= '<ul class="level1 menu-product' . $level . '">';
     }
     $avg = 0;
     $ratings = array();
     foreach ($_productCollection as $_product) {
         $productId = $_product->getId();
         $reviews = Mage::getModel('review/review')->getResourceCollection()->addStoreFilter(Mage::app()->getStore()->getId())->addEntityFilter('product', $productId)->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)->setDateOrder()->addRateVotes();
         if ($i < $number) {
             if ($number < 3) {
                 if ($i % 2 == 0) {
                     if ($level == 0) {
                         $wproduct = 100 / 2;
                     }
                     $levelproduct = 'levelproducttow fast';
                 } else {
                     if ($level == 0) {
                         $wproduct = 100 / 2;
                     }
                     $levelproduct = 'levelproducttow';
                 }
             } else {
                 if ($i % 3 == 0) {
                     if ($level == 0) {
                         $wproduct = 100 / 3;
                     }
                     $levelproduct = 'levelproduct fast';
                 } else {
                     if ($level == 0) {
                         $wproduct = 100 / 3;
                     }
                     $levelproduct = 'levelproduct';
                 }
             }
             if ($level == 0) {
                 $html .= '<li class="level2 ' . $levelproduct . '" style="width:' . $wproduct . '%;">';
                 $html .= '<a href="' . $_product->getProductUrl() . '" title="' . $this->htmlEscape($_product->getName()) . '"> 
                       <img src="' . $this->helper('catalog/image')->init($_product, 'small_image')->resize() . '" alt="' . $this->htmlEscape($_product->getName()) . '" title="' . $this->htmlEscape($_product->getName()) . '"/></a>';
             } else {
                 $html .= '<li class="level2 ' . $levelproduct . '">';
                 if ($widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_left'] == 1 || $widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_right'] == 1) {
                     $html .= '<a href="' . $_product->getProductUrl() . '" title="' . $this->htmlEscape($_product->getName()) . '"> 
                       <img src="' . $this->helper('catalog/image')->init($_product, 'small_image')->resize() . '" alt="' . $this->htmlEscape($_product->getName()) . '" title="' . $this->htmlEscape($_product->getName()) . '"/></a>';
                 } else {
                     $width = Mage::getStoreConfig('megamenu/mainmenu/width_thumbnail_category');
                     $height = Mage::getStoreConfig('megamenu/mainmenu/height_thumbnail_category');
                     $html .= '<a href="' . $_product->getProductUrl() . '" title="' . $this->htmlEscape($_product->getName()) . '"> 
                       <img src="' . $this->helper('catalog/image')->init($_product, 'small_image')->resize() . '" alt="' . $this->htmlEscape($_product->getName()) . '" title="' . $this->htmlEscape($_product->getName()) . '" width="' . $width . '" ; height="' . $height . '"/></a>';
                 }
             }
             $html .= '<a href="' . $_product->getProductUrl() . '" title="' . $this->htmlEscape($_product->getName()) . '"> <span class="product-name">' . $_product->getName() . '</span></a>';
             if ($level == 0) {
                 if (count($reviews) > 0) {
                     foreach ($reviews->getItems() as $review) {
                         foreach ($review->getRatingVotes() as $vote) {
                             $ratings[] = $vote->getPercent();
                         }
                     }
                     $avg = array_sum($ratings) / count($ratings);
                 }
                 $html .= '<div class="rating-box"><div class="rating" style="width:' . ceil($avg) . '%;"></div></div>';
             } else {
                 if ($widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_left'] == 1 || $widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_right'] == 1) {
                     if (count($reviews) > 0) {
                         foreach ($reviews->getItems() as $review) {
                             foreach ($review->getRatingVotes() as $vote) {
                                 $ratings[] = $vote->getPercent();
                             }
                         }
                         $avg = array_sum($ratings) / count($ratings);
                     }
                     $html .= '<div class="rating-box"><div class="rating" style="width:' . ceil($avg) . '%;"></div></div>';
                 }
             }
             $html .= Mage_Catalog_Block_Product::getPriceHtml($_product, true);
             if ($level == 0) {
                 $html .= '<a href="' . $this->helper('checkout/cart')->getAddUrl($_product) . '"><button class="button btn-cart btn-featurecart btn-carthover2" onclick="productAddToCartForm.submit(this)"><span><span>Add to Cart</span></span></button></a>';
                 $html .= '<ul class="add-to-links">';
                 $html .= '<li><a href="' . $this->helper('wishlist')->getAddUrl($_product) . '" class="link-wishlist">' . $this->__('Add Wishlist') . '</a></li>';
                 $html .= '<li><a href="' . $this->getAddToCompareUrl($_product) . '" class="link-compare">' . $this->__('Add Compare') . '</a></li>';
                 $html .= '</ul>';
             } else {
                 if ($widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_left'] == 1 || $widthc[0]['active_static_block'] == 1 && $widthc[0]['active_static_block_right'] == 1) {
                     $html .= '<ul class="add-to-links">';
                     $html .= '<li><a href="' . $this->helper('wishlist')->getAddUrl($_product) . '" class="link-wishlist">' . $this->__('Wishlist') . '</a></li>';
                     $html .= '<li><a href="' . $this->getAddToCompareUrl($_product) . '" class="link-compare">' . $this->__('Compare') . '</a></li>';
                     $html .= '</ul>';
                 }
             }
             $html .= '</li>';
             $i++;
         }
     }
     $html .= '</ul>';
     return $html;
 }
コード例 #7
0
 public function recentlyViewedAction()
 {
     $product_contro_re = new Mage_Catalog_Block_Product();
     $html = '';
     if ($_products = Mage::getSingleton('Mage_Reports_Block_Product_Viewed')->getItemsCollection()) {
         $count = count($_products);
         $limit = (int) Mage::getStoreConfig('inchoo_notes_general/feed/recent_count');
         $html .= "<section id='recView'>\r\n\t\t\t\t\t<div class='asLook'>\r\n\t\t\t\t\t\t<ul id='mycarousel-recView' class='jcarousel-skin-tango'>";
         $i = 0;
         foreach ($_products as $_product) {
             $product = Mage::getModel('catalog/product')->load($_product->getId());
             $_productname = $product->getName();
             if (strlen($_productname) > 27) {
                 $_productname = substr($_productname, 0, 24) . '...';
             }
             $defPrice = $product->getPrice();
             $specialprice = 0;
             $_taxHelper = Mage::helper('tax');
             $currentDate = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
             $currentDate = date("Y-m-d h:m:s", $currentDate);
             if (!$product->isConfigurable()) {
                 $specialToDate = $product->getSpecialToDate();
                 $specialFromDate = $product->getSpecialFromDate();
                 if (($currentDate >= $specialFromDate && $currentDate < $specialToDate || $specialToDate == "") && $product->getSpecialPrice() != 0) {
                     $price = $product->getResource()->getAttribute('price')->getFrontend()->getValue($product);
                     $price = $product->getSpecialPrice();
                 } else {
                     $price = $product->getFinalPrice();
                 }
             } else {
                 $price = $product->getPrice();
             }
             $priceRe = $product_contro_re->getPriceHtml($_product, true);
             if ($i < $limit) {
                 $html .= "<li><div class='BestPro'>\r\n\t\t\t\t\t\t\t<a href='" . $_product->getProductUrl() . "' title='" . $_productname . "' class='product-image'>\r\n\t\t\t\t\t\t\t<img src='" . Mage::helper('catalog/image')->init($_product, 'small_image')->resize(238, 249) . "' width='238' height='249' alt='" . $_product->getName() . "' /></a>\r\n\t\t\t\t\t\t\t<div class='BestProDetails'>" . $_product->getName() . "</div>\r\n\t\t\t\t\t\t\t<div class='BestProDetailsPrice'>" . $priceRe . "</div></div></li>";
             }
             $i++;
         }
         $html .= "</ul></div></section>";
         $scroll_items = (int) Mage::getStoreConfig('inchoo_notes_general/feed/recent_scroll');
         if ($scroll_items <= 0) {
             $items = 1;
         } else {
             $items = $scroll_items;
         }
         $html .= "<script type='text/javascript'>\r\n\t\tjQuery(document).scroll(function() {\r\n\t\t\tjQuery('#mycarousel-recView').jcarousel({ horizontal: true, scroll: " . $items . "});\r\n\t\t});\r\n\t\t</script>";
     }
     $this->getResponse()->setBody($html);
 }
コード例 #8
0
 protected function _toHtml()
 {
     $html = '';
     $showSugg = true;
     $showProd = true;
     if (!$this->_beforeToHtml()) {
         return $html;
     }
     $html .= '<ul class="ajaxsearch"><li style="display:none"></li>';
     $titleSugg = "<li class='head'>Search Suggestions</li>";
     $titleProd = "<li class='head'>Products</li>";
     //Check if products exist for the search text
     $results = $this->getSuggestProducts();
     if (!$results->getSize()) {
         $showProd = false;
         //If product do not exist how can the suggestion be, do not show the suggestion also
         $showSugg = false;
     }
     $suggestData = $this->getSuggestData();
     if (!($count = count($suggestData))) {
         $showSugg = false;
         //return $html;
     }
     $count--;
     if ($showSugg) {
         $html .= $titleSugg;
         foreach ($suggestData as $index => $item) {
             if ($index == 0) {
                 $item['row_class'] .= ' first';
             }
             if ($index == $count) {
                 $item['row_class'] .= ' last';
             }
             $title = $this->htmlEscape($item['title']);
             //Get actual string (case sensitive) matched in product name
             $pos = stripos($title, $this->helper('catalogsearch')->getQueryText());
             $actualStr = substr($title, $pos, strlen($this->helper('catalogsearch')->getQueryText()));
             if (strlen($title) > 48) {
                 $title = substr($title, 0, 45) . '...';
             }
             //$html .=  '<li title="'.$this->htmlEscape($item['title']).'" class="'.$item['row_class'].'">'
             //  . '<span class="amount">'.$item['num_of_results'].'</span>'. $title .'</li>';
             //$html .=  '<li title="'.$item['title'].'" class="'.$item['row_class'].'">'
             //  . '<span class="amount">'.$item['num_of_results'].'</span>'. str_ireplace($this->helper('catalogsearch')->getQueryText(), '<b>'.$actualStr.'</b>', $title) .'</li>';
             $html .= '<li title="' . $item['title'] . '" class="' . $item['row_class'] . '">' . str_ireplace($this->helper('catalogsearch')->getQueryText(), '<b>' . $actualStr . '</b>', $title) . '</li>';
         }
     }
     ##########		Added By Vishal		###############
     if ($showProd) {
         $html .= $titleProd;
         $counter = 0;
         //print "<pre>";
         //print_r($results->getData());
         //print "</pre>";
         foreach ($results as $pro) {
             $row_class = ++$counter % 2 ? 'even' : 'odd';
             if ($counter == $results->getSize()) {
                 $row_class .= ' last';
             }
             $prod = Mage::getModel('catalog/product')->load($pro->getId());
             //print $prod->getName().'====='.$prod->getFinalPrice()."+++++++++++++++";
             $theProductBlock = new Mage_Catalog_Block_Product();
             //Get actual string (case sensitive) matched in product name
             $prodName = strlen(strip_tags($pro->getName())) > 39 ? substr(strip_tags($pro->getName()), 0, 36) . '...' : strip_tags($pro->getName());
             $pos = stripos($prodName, $this->helper('catalogsearch')->getQueryText());
             $actualStr = substr($prodName, $pos, strlen($this->helper('catalogsearch')->getQueryText()));
             $pos = stripos($pro->getName(), $this->helper('catalogsearch')->getQueryText());
             $actualStr = substr($pro->getName(), $pos, strlen($this->helper('catalogsearch')->getQueryText()));
             $html .= "<li class=\"preview {$row_class}\" ><a href=\"{$pro->getProductUrl()}\">";
             $html .= "<img src=\"{$this->helper('catalog/image')->init($pro, 'small_image')->resize(50, 50)}\"  />";
             $html .= str_ireplace($this->helper('catalogsearch')->getQueryText(), '<b>' . strtolower($actualStr) . '</b>', ucfirst(strtolower($prodName)));
             $description = strlen(strip_tags($pro->getDescription())) > 41 ? substr(strip_tags($pro->getDescription()), 0, 38) . '...' : strip_tags($pro->getDescription());
             //$description=wordwrap($description, 30, '<br>', true);
             $description = ucfirst(strtolower($description));
             $html .= "<div class=\"description\">" . $description . "</div>";
             //$html .=  "<div class=\"description\"><span class="priceBlock">Price</span> ".Mage::helper('core')->currency($prod->getFinalPrice(),true,false)."</div>";
             $html .= "<div class=\"description\"><span class='priceBlock'>Price</span> " . $theProductBlock->getPriceHtml($prod, true) . "</div>";
             $html .= "</a></li>";
         }
     }
     ##########		Added By Vishal		###############
     if (!$showProd && !$showSugg) {
         $html .= '<li>Oops! No product found.</li>';
     }
     $html .= '</ul>';
     return $html;
 }