Jump to content
Sign in to follow this  
compstudent

PHP Attribute Filter Help

Recommended Posts

First I would like to say that I am so grateful for stumbling across this website for help and I am definitely going to be a regular.. 

 

 

I am trying to display all the Categories and Sub-category that are filtered by attribute 'manufacturer'. I need help with inputing attribute 'manufacturer' . I am trying to write this for Magento. Thank you so much!

<?php
	

	?>
	
		<div class="col-main grid-full no-gutter in-col1"> 
			<div class="std"> 
                <div class="subcat-wrapper">

<?php
	$category = $this->getCategory();
	$categories = $this->getSubcategories($category);
	$baseUrl = Mage::getBaseUrl('media')."catalog/category/";

	// Starting a loop with varible cat.
	foreach($categories as $cat)
	{

?>

<!--START <?php echo strtoupper($cat->getName()); ?>-->
<div class="grid-full no-gutter"> 

    <div class="grid-full no-gutter" id="category-wrapper">

        <div class="cat-img-wrapper">
            <div class="category-image-wrapper">
                <img src="<?php
							// This will currently return null, as no image is set.
							// Using filler image until set.
							// Not sure what format image is in, assumming it's a url to the correct image, but could be wrong.

							$imageUrl = $cat->getThumbnail(); // Grabs the thumbnail image of the category

							if ($imageUrl == null)
							{
								// Using the filler image from general mockup,
								// Should either replace with something more general (eg a question mark)
								// This code might want to be used even after images are set, in case an image is not set, or if there are server issues.
								$imageUrl = "IMAGE URL"; // TODO change
							} else {
								$imageUrl = $baseUrl.$imageUrl; // concatenates the thumbnail image of the category with the
							}
							// If the image from getData("image") is not an image url, refactor this.
							echo $imageUrl;
							// Unsetting image url to avoid potential issues.
							unset($imageUrl);
							?>"
					alt="<?php echo $cat->getName(); ?>">
            </div>
        </div>

        <div class="cat-desc-wrapper" id="category-description-wrapper">
            <div class="category-description-inner-wrapper">
             <h1 class="category-header"><?php echo $cat->getName(); ?></h1>
            <p>

				<?php
							// This is currently returning null.
							// Replacing with filler until description is no longer empty.

							$description = $cat->getData("description");

							if ($description == null)
							{
								// This is the filler text that was used for the orig mockup
								// Should replace with something more appropriate to general purpose.
								// Using this after getting correct desc might be unnessicary.
								$description = "This is a paragraph describing small equipment and all of its varied uses throughout a foodservice establishment. Small foodservice equipment is not hard to find or buy at Bargreen Ellingson. We are one of the nation's leading suppliers. Small foodservice equipment is not hard to find or buy at Bargreen Ellingson. We are one of the nation's leading suppliers.";
							}

							echo $description;
							// Unsetting description to avoid potential errors.
							unset($description);

						?>

				</p>
			</div>
        </div>

    </div>

</div>

<div class="grid-container">

<!--START <?php echo strtoupper($cat->getName()); ?> PRODUCT TYPES-->

	<?php

	
		$subCats = $this->getSubcategories($cat);
		// Starting a forloop with varible subCat
		foreach($subCats as $subCat)
		{
	?>

	
<!--<?php echo strtoupper($subCat->getName()); ?>-->
<div class="grid12-2 mobile-grid-half no-gutter item-block">
<a href="/<?php echo $subCat->getData('url_path'); ?>">


            <div class="product-type-image-wrapper">
                <img src="
					<?php
							// This will currently return null, as no image is set.
							// Using filler image until set.
							// Not sure what format image is in, assumming it's a url to the correct image, but could be wrong.

							$imageUrl = $subCat->getThumbnail();

							if ($imageUrl == null)
							{
								// Using the filler image from general mockup,
								// Should either replace with something more general (eg a question mark)
								// This code might want to be used even after images are set, in case an image is not set, or if there are server issues.
								$imageUrl = "IMAGE URL";
							} else {
                                $imageUrl = $baseUrl.$imageUrl;
                            }
							// If the image from getData("image") is not an image url, refactor this.
							echo $imageUrl;
							// Unsets image url, to avoid potential errors.
							unset($imageUrl);
							?>" alt="<?php echo $subCat->getName(); ?>">
            </div>

            <div class="product-type-name-wrapper">
                 <p class="product-type-name"><?php echo $subCat->getName(); ?></p>
            </div>

        
</a>
</div>
			<?php
			
		}// Ends for each loop (subcat)
		// Unsetting for loop variable, as for loops don't always unset after usage in php.
		unset($subCat);

		?>
		

<!--END <?php echo strtoupper($cat->getName()); ?> PRODUCT TYPES-->
<!--END <?php echo strtoupper($cat->getName()); ?> SECTION-->
</div>

		<?php

	}// Ends for each loop (cat)
	// Unsetting for loop variable, as for loops don't always unset local vars in php
	unset($cat);
?>
	<div class="postscript grid-full in-col1"></div>
            </div>                
</div> 
</div>


Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.