Having issues with getting products in main category


(raznawa) #1

hi
i am creating a showcase site website, everything is fine but while getting products i am having issues . i have multiple categories like

Pre School [ Nursery / LKG / UKG - these are in subcategory inside pre school ]
Class 1 [ this has no sub categories ]

i have added books [ products in all categories including main category [ Pre School ] and the single category Class 1.

but now what i am facing is when i click on sub categories [ Nursery / LKG / UKG ] i can see the products but when i clicked on main category [ Pre School ] i see only categories nut not any products ]
i have also added products in Class 1 [ Single category but even i clicked in class 1 i can’t see any products .

can anyone please help me with this

the code i have used for this is added below

<?php if(!empty($subCategories)){ foreach ($subCategories as $cat) { echo '
  • '; echo ''.'>> '.$cat->cat_title.'   '.''; echo "
  • "; } }else{ ?>
                            <div class="col-sm-12">
                              
                                <div class="collection-product-wrapper">
                                    
                                    <div class="product-wrapper-grid">
                                        <div class="row">
                                         
                                         
                                         
                                   <?php foreach($books as $book): ?>
                <?php $bookImages = BookImages::model()->findAllByAttributes( array('book_id' => $book->id)); ?>
                <?php $bookImage = $bookImages[0]; ?> 
                
                      
                                          <div class="col-xl-3 col-md-4 col-6 col-grid-box">
                                                <div class="product-box">
                                                    <div class="img-block">
                                                      
                                                    
                                                       <a href="<?php echo $this->createUrl('/book/'.$book->id.'/'.friendlyUrl($book->prod_title));?>" class="bg-size" style="background-image: url('<?php echo Yii::app()->baseUrl; ?>/uploads/<?php echo $bookImage->img_path;?>'); background-size: cover; background-position: center center; background-repeat: no-repeat; display: block;"><img src="<?php echo Yii::app()->baseUrl; ?>/uploads/<?php echo $bookImage->img_path;?>" class=" img-fluid bg-img" alt="" style="display: none;"></a>
                                            
                                        
                                                    </div>
                                                    <div class="product-info">
                                                        <div>
                                                          
                                                             
                                                             <a href="<?php echo $this->createUrl('/book/'.$book->id.'/'.friendlyUrl($book->prod_title));?>"><h6>test <?php echo $book->prod_title;?></h6></a>
                                                           <?php /*?> <h6><?php echo $book->price;?></h6>
                                                            <h6><?php echo $book->authors;?></h6><?php */?>
                                                        </div>
                                                    </div>
                                                  
                                                </div>
                                            </div>
                                            
                                            
                                            
                                            
                                            
                                              <?php endforeach; ?> 
                             <?php } //end of if(!empty($subCategories)) ?>   
                                            
                                            
                                            
                                            
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            
                                       
                                         
                                         
                                         
                        </div>
                    </div>
                </div>
    

    Thank you !