-
- PaulAlford

-
Total Posts: 64
Joined: 2007-12-04
Summerville, SC
|
Here’s a related issue with showing items on the HomePage....
I am just using the default theme, which shows the Most Popular Products down below, but I can’t seem to get many of the “see all boats” or whatever link to work. I have been able to edit the rest to make the 6 pics show mine and get the item link to work right… just NOT the “See others in the category” link. I got 1 to work, but I even tried copy and pasting that one for the others (and edited to go to that category) but still wont work !! Errrrrr.. Here is the code for the “See all Shoes” link - maybe someone can see something I am not.
<a href="{{store url=""}}boat-wrap.html"><img class="product-img" src="{{skin url=’images/media/best_selling_img06.jpg’}}” border="0" width="95" /></a>
<div class="product-description">
<p>
<a href="{{store url=""}}boat-wrap.html">18-20ft Boat Wrap</a>
</p>
<p>See all <a href="{{store url="boat-wraps"}}">Boat Wraps</a></p>
I know that “boat-wraps” in the SEE ALL line is copied from the boat wraps category URL and that IS what is in the category page url, but it wont actually WORK on the home page link.
Go see yourself… http://www.WrapitSigns.com/store
|
| |
|
 |
 |
 |
|
|
-
- patriciamg

-
Total Posts: 12
Joined: 2008-03-14
|
Hello All!
I´ve done the recomended step:
{{block type="catalog/product_new" template="catalog/product/new.phtml"}}
But I´m having one big problem....
I have 20 new products to display in the home, but only five of them show up, in one single line…
Shouln´t the system generate the number of lines needed to display all products? or at least have a “next page” link to show the rest?
Please Help!
Thanks,
Patrícia
ps: my product/category configuration is correct, so that´s not the cause.
|
| |
|
 |
 |
 |
|
|
-
- Flowstack

-
Total Posts: 130
Joined: 2008-01-30
London, United Kingdom
|
@ patriciamg - Have you tried changing this line in \app\code\core\Mage\Catalog\Block\Product\New.php
$products->setOrder('news_from_date')->setPageSize(5)->setCurPage(1);
Change 5 to whatever you want.
I’m just guessing as I haven’t tested this.
|
| |
|
 |
 |
 |
|
|
-
- patriciamg

-
Total Posts: 12
Joined: 2008-03-14
|
I´ve done that...but it keeps using just one line...and it destroys the layout…
|
| |
|
 |
 |
 |
|
|
-
- PaulG

-
Total Posts: 2
Joined: 2008-03-22
|
At this point I’m setting up a new webshop. For that I’m using the solution that Dan_W provided (thank you for that) to show some featured products on the homepage. I want to show 4 or 5 randomly chosen products because I have selected more than 5 products marked as featured products. How can you select random products. From my investication on the forum and through other files I did understand that I should use ->setOrder(’RAND()’), but this isn’t working for me.
I have tried “->setOrder(’RAND()’)” this isn’t working.
I’ve tried “->setOrder(’BY RAND()’)” this isn’t working.
I’ve tried “->setOrder(’price’, ‘ASC’)” this is sorting in a way I would expect.
I’ve tried “->setOrder(’price’, ‘DESC’)” this is sorting in a way I would expect.
Below is the code what I use to change the ordering. Hopefully that somebody can help me with this.
I’m using version 1.0.
Thanks
Whole code:
class Mage_Catalog_Block_Product_Homepage extends Mage_Catalog_Block_Product_Abstract { public function __construct() { parent::__construct();
$storeId = Mage::app()->getStore()->getId(); $product = Mage::getModel('catalog/product'); /* @var $product Mage_Catalog_Model_Product */ $todayDate = $product->getResource()->formatDate(time()); $products = $product->setStoreId($storeId)->getCollection() ->addAttributeToFilter('home_page_featured', array('yes'=>true)) ->addAttributeToSelect(array('name', 'price', 'small_image', 'short_description'), 'inner') ->addAttributeToSelect(array('special_price', 'special_from_date', 'special_to_date'), 'left') ->setOrder('price', 'ASC') ->setPageSize(4) ; /* @var $products Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
// $products->setOrder('hot_deals')->setPageSize(4)->setCurPage(1);
$this->setProductCollection($products); } }
|
| |
|
 |
 |
 |
|
|
-
- patriciamg

-
Total Posts: 12
Joined: 2008-03-14
|
Hello again...isn´t anybody else getting the same problem?! Everyone can display the new products in multiple lines at the home page??
|
| |
|
 |
 |
 |
|
|
|
|
-
- chinesedream

-
Total Posts: 745
Joined: 2007-08-31
San Francisco, CA
|
dan_w,
Is it possible to have the small image resize in propotion?
I have this GD2 (http://www.magentocommerce.com/boards/viewthread/5502/)
and removed the ‘->resize(95,95)”
my new code
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image'); ?>” alt="<?php echo $this->htmlEscape($_product->getName()) ?>” width="95" />
But I am getting these errors:
_imageSrcWidth / $this->_imageSrcHeight; $dstWidth = round($dstHeight * $width2height); } elseif( !isset($dstHeight) ) { $height2width = $this->_imageSrcHeight / $this->_imageSrcWidth; $dstHeight = round($dstWidth *
Thank you very much!
|
| |
|
 |
 |
 |
|
|
-
- cshontz

-
Total Posts: 85
Joined: 2007-11-07
|
Any thoughts on using Dan’s brilliant example to display a variation of “New Products”, but without manually specifying the “New from Date” and “New to Date” values in attributes?
For instance, as we add product, the six most recently added products are always displayed in a format similar to the “Best Selling Products” example. We’re constantly adding product, so it stays pretty fresh. The database does contain a “created_at” value for product entities, so it should be possible without using attributes.
|
| |
|
 |
 |
 |
|
|
-
- cshontz

-
Total Posts: 85
Joined: 2007-11-07
|
To display the most recently created products using a variation of Dan’s homepage sample, make the following changes to Homepage.php:
1) Comment out (//), or remove the line that filters products by a particular attribute - in this case, the “home_page_featured” attribute. Doing so will return all products.
->addAttributeToFilter('home_page_featured', array('yes'=>true))
Becomes
// ->addAttributeToFilter('home_page_featured', array('yes'=>true))
2) Change the line that specifies sort order from “hot_deals” (or whatever), to “created_at”. Setting the page size in this line will limit results to “x” number.
$products->setOrder('hot_deals')->setPageSize(5)->setCurPage(1);
Becomes
$products->setOrder('created_at')->setPageSize(5)->setCurPage(1);
That’s all there is to it. Anyone is welcome to improve upon, optimize, or provide further explanation for this technique. I’m doing things by trial and error, which might not always be the best way. Many thanks to all who have contributed to this thread so far.
|
| |
|
 |
 |
 |
|
|
-
- chinesedream

-
Total Posts: 745
Joined: 2007-08-31
San Francisco, CA
|
Hmm, nice! Thank you! I wonder if we can have both, hot deals and created at in one homepage.php (.phtml) file?
I think it’s nice to be able to show hot deals (or featured products) and newly added product, because the lateral isn’t always the featured products the store owner wanted.
|
| |
|
 |
 |
 |
|
|
-
- cshontz

-
Total Posts: 85
Joined: 2007-11-07
|
I’m in the same boat as PaulG, as I want to randomize the results of an attribute-based lookup. I don’t think setOrder will accept a “random” parameter (although that’d be nice). I think I can get something working based on Martin’s example in this thread, but I’d prefer something a little more similar to Dan’s approach - just to be consistent more than anything else.
|
| |
|
 |
 |
 |
|
|
-
- cshontz

-
Total Posts: 85
Joined: 2007-11-07
|
I’ve managed to randomize results of an attribute-based lookup. I found an existing function within Magento’s core that works nicely. The problem is, however, the function is in the wrong class (and file), and I don’t want to modify a core file. Unfortunately, my Kung Fu isn’t strong enough to get it to work without altering the core file, as I’ve been trying for a few hours.
When placed in the appropriate class, this
public function setRandomOrder()
randomizes the results of Dan’s “featured on home page” results. Syntax looks like this
$products = $product->setStoreId($storeId)->getCollection() ->addAttributeToFilter('home_page_featured', array('yes'=>true)) ->addAttributeToSelect(array('name', 'price', 'small_image'), 'inner') ->addAttributeToSelect(array('special_price', 'special_from_date', 'special_to_date'), 'left') ->setRandomOrder() ->setPageSize(4) ->setCurPage(1);
However, I’ve tried placing the contents of the setRandomOrder function into the Homepage.php file to no avail. I’m sure my problem here is a lack of understanding of PHP classes and whatnot. Any tips?
|
| |
|
 |
 |
 |
|
|
-
- dan_w

-
Total Posts: 245
Joined: 2008-01-04
|
What’s the function and where did you find it?
|
| |
|
 |
 |
 |
|
|
-
- cshontz

-
Total Posts: 85
Joined: 2007-11-07
|
Thanks, Dan.
public function setRandomOrder() { $this->getSelect()->order(new Zend_Db_Expr('RAND()')); $this->_setIdFieldName('link_id'); return $this; }
Found in app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Link/Product/Collection.php, and when you add the function to the class in app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php, it randomly sorts the product collection in your Homepage.php.
|
| |
|
 |
 |
 |
|
|