cancel
Showing results for 
Search instead for 
Did you mean: 

Featured Product slider geeft "Simple Product" niet weer

Featured Product slider geeft "Simple Product" niet weer

Hallo Magento Forum!

 

Voor een Magento webshop heb ik een blok weergegeven op de homepagina met daarin een slider van aanbevolen producten.

De slider werkt helemaal goed en laad gewoon Configurable Products zien.

 

Het probleem is dat hij Simple Products niet weergeeft in de slider

 

Er moet dus ergens in de code een filter zitten die er voor zorgt dat de simple products niet worden weergegeven, echter kan ik deze nergens vinden.

 

Met  de volgende code laadt ik de slider in op de homepagina:

{{block type="catalog/product_list" num_products="8" name="featuredproduct" as="featuredproduct" template="catalog/product/featured.phtml" }}

 

 

Dit is de inhoud van featured.phtml:

 

<?php
              // some helpers
              $_helper = $this->helper('catalog/output');
              $storeId = Mage::app()->getStore()->getId();
              $catalog = $this->getLayout()->createBlock('catalog/product_list')->setStoreId($storeId);
              $productCount = $this->getData('num_products');

$visibility = array( 
                    Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, 
                    Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                );
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
              ->setCodeFilter('magikfeatured')
              ->getFirstItem();
  $attribute_info = $attributeInfo->getData();
 
  if($attribute_info['attribute_code'] == 'magikfeatured'){
$collection = Mage::getResourceModel('reports/product_collection') 
                      ->addAttributeToSelect('*')     
                      ->setStoreId($storeId) 
                      ->addStoreFilter($storeId)     
                      ->addAttributeToFilter('visibility', $visibility)
                      ->addAttributeToFilter('magikfeatured', true) 
                      ->setOrder('updated_at', 'desc')
                      ->addAttributeToSelect('status') 
                      ->setPageSize($productCount);
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
$collection->joinField('is_in_stock','cataloginventory/stock_item','is_in_stock','product_id=entity_id')->addAttributeToFilter('is_in_stock', 1);

/*  To display product by category id */
if($categoryId=$this->getData('category_id')){
      $category = Mage::getModel('catalog/category')->load($categoryId);
      $collection->addCategoryFilter($category);
    } ?>

<div class="featured-slider">
  <div class="new_title center">
    <h2><span><?php echo $this->__('Featured Products') ?></span></h2>
  </div> <!--new_title center-->

<?php             // if no products are currently featured, display some text
              if (!$collection->count()) :
?>
      <p class="note-msg"><?php echo $this->__('There are no featured products at the moment.') ?></p>
      <?php else : ?>

<a id="products_slider_prev" class="jcarousel-prev-horizontal2" href="#"></a> <a id="products_slider_next" class="jcarousel-next-horizontal2" href="#"></a>
<div class="jcarousel-skin-tango5">
  <div class="jcarousel-container jcarousel-container-horizontal" style="position: relative; display: block;">
    <div class="jcarousel-clip jcarousel-clip-horizontal" style="overflow: hidden; position: relative;">
      <ul id="featured_products_slider" class="products-grid jcarousel-list jcarousel-list-horizontal" style="overflow: hidden; position: relative; top: 0px; margin: 0px; padding: 0px; left: 0px; width: 2460px;">
        <?php
                $_collectionSize = $collection->count();
                $_columnCount = 4;
                $i = 0;
               
                foreach ($collection as $_product) :
                        $_product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($_product->getId());

        ?>
        <?php if ($i++%$_columnCount==0): ?>            
        <?php endif ?>  
    <li class="item jcarousel-item jcarousel-item-horizontal jcarousel-item-1 jcarousel-item-1-horizontal <?php if(($i-1)%$_columnCount==0): ?>first1<?php elseif($i%$_columnCount==0): ?> last1<?php elseif($i%$_columnCount!==0): ?> odd1<?php endif; ?>">
   <div class="item-inner">
     <div class="product-block">
        <div class="product-image">
          <a href="<?php echo $_product->getProductUrl() ?>">
            <figure class="product-display">
          <?php echo $this->helper('ventosettings')->getLabel($_product);  ?>
          <img class="lazyOwl product-mainpic" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(268,325) ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
          <img class="product-secondpic" src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(268,325) ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
            </figure>
          </a>
        </div> <!--product-image-->
        <div class="product-meta">
           <div class="product-action">
              <?php if($_product->isSaleable()): ?>
                <a href="<?php echo $this->getAddToCartUrl($_product) ?>" class="addcart"> <i class="icon-shopping-cart">&nbsp;</i><?php echo $this->__('Add to Cart') ?></a>
              <?php else: ?>
                <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
              <?php endif; ?>
              <a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="wishlist" title="<?php echo $this->__('Add to Wishlist');?>"><i class="icon-heart">&nbsp;</i></a>
              <?php if(Mage::app()->getStore()->getConfig('ventosettings/ventosettings_quickview/enable')==1){?>
                  <a data-fancybox-type="ajax" onclick="callQuickView('<?php echo Mage::getUrl('ventosettings/index/view/id/'.$_product->getId());?>');" title="<?php echo $this->__('Quick View') ?>" class="quickview"><i class="icon-zoom">&nbsp;</i></a>                    
              <?php }  ?>   
           </div> <!--product-action-->
        </div> <!--product-meta-->
     </div> <!--product-block-->

     <div class="item-info">
       <div class="info-inner">
          <div class="item-title">
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
                  <?php $prod_name = $this->htmlEscape($_product->getName()) ; 
                  if(strlen($prod_name) > 30) {echo substr($prod_name,0,30)."...";}else {echo $prod_name;}?>
            </a>
          </div> <!--item-title-->
          <div class="item-content">
            <div class="item-price">
              <?php echo $this->getPriceHtml($_product, true) ?>
            </div> <!--item-price-->
                    <?php
                        $summaryData = Mage::getModel('review/review_summary')
                                ->setStoreId($storeId)
                                ->load($_product->getId());
                        if($summaryData->getRatingSummary()) { ?>
                          <div class="rating">
                            <div class="ratings">
                                <div class="rating-box">
                                        <div class="rating" style="width: <?php echo $summaryData->getRatingSummary().'%'; ?>"></div>
                                </div> <!--rating-box-->
                            </div> <!--ratings-->
                          </div> <!--rating-->
                    <?php } else { ?>  
                            <div class="rating"><div class="ratings"><div class="rating-box"><div style="width:0%" class="rating"></div></div></div></div>
                    <?php } ?>
          </div> <!--item-content-->
       </div> <!--info-inner-->
     </div> <!--item-info-->
   </div> <!--item-inner-->
</li> <!--item jcarousel-item jcarousel-item-horizontal jcarousel-item-1 jcarousel-item-1-horizontal-->   
            <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>            
            <?php endif ?>      
                <?php endforeach ?> 
       </ul>
     </div> <!--jcarousel-clip jcarousel-clip-horizontal-->
  </div> <!--jcarousel-container jcarousel-container-horizontal-->
</div> <!--jcarousel-skin-tango5-->
      <?php endif ?>  <!--Endif !$collection->count() -->
</div> <!--featured-slider-->
<?php } ?> <!-- chk attribute_code -->

<script type="text/javascript">
jQuery(document).ready(function($) {

        function mycarousel_initCallback(carousel) {

            $('#products_slider_next').bind('click', function() {
                carousel.next();
                return false;
            });
            $('#products_slider_prev').bind('click', function() {
                carousel.prev();
                return false;
            });
        };

    $('#featured_products_slider').jcarousel({
            scroll: 1,
        initCallback: mycarousel_initCallback,
            buttonNextHTML: null,
            buttonPrevHTML: null
    });
});
</script>

<div id="mgkquickview">
<div id="magikloading" style="display:none;text-align:center;margin-top:400px;"><img src="<?php echo $this->getSkinUrl('images/mgkloading.gif');?>" alt="loading">
</div></div>
<script type="text/javascript">
function callQuickView(qurl) { 
    jQuery('#mgkquickview').show();
    jQuery('#magikloading').show();
    jQuery.get(qurl, function(data) {
      jQuery.fancybox(data);
      jQuery('#magikloading').hide();
jQuery('#mgkquickview').hide();
    });
 }
 
</script>

Wie oh wie kan mij op het juiste pad sturen?

 

Mijn dank zal groot zijn!

 

Groet,

 

Anton

2 REPLIES 2

Re: Featured Product slider geeft "Simple Product" niet weer

Heb je in het simpel product de waarde van het attribuut magikfeatured op Ja staan?
De product slider filtert hier op in

->addAttributeToFilter('magikfeatured', true)

 

Re: Featured Product slider geeft "Simple Product" niet weer

Jup,

Ik heb een custom attribute aangemaakt die daar aan gekoppeld is. Wanneer ik dit voor Configurable product op ja zet komt deze gewoon in de slider, maar Simple product dus niet.