Hide toolbar elements on specific Magento category page - magento

I have a custom homepage on my Magento store which displays the latest 150 added products, with the most recent first.
The paging on the toolbar is needed here (30 per page, 5 pages) but the "sort by" and the "Show" number to display are both irrelevant.
The page is constructed using Tridian New Arrivals code (google it), with a minor tweak to sort the collection by entity_id descending, as the created_at sort (suggested in the article) seems to not work correctly.
So this is basically a home page redirect to a category page, which has an over-ride in place to display a specific product collection (the new arrivals).
Could someone show me how to hide those two select lists on just this page please?
Cheers,
Rob

Theoretically this is possible with a layout update in the category design, but it has not been so easy:
http://www.magentocommerce.com/boards/v/viewthread/46823/#t331000
You can create a new theme that consists of just the files needed to be changed to get rid of the toolbar (hacked phtml file) and then set the custom design for this category to this theme. It will use your default theme to fill in the gaps, e.g. header, footer etc.

I resolved this in code, in toolbar.phtml, as follows:
First I set a current category variable at the start of the code (mine is at line 36).
<?php
if (Mage::registry('current_category') != NULL) {
$curr_category = Mage::registry('current_category')->getName();
$curr_category = strtolower($curr_category);
} else {
$curr_category = '';
}
?>
Then I test the variable value in an IF statement around the code blocks that build and output the select lists.
<?php if($curr_category != 'new arrivals'): ?>
--- Select list code here ---
<?php endif; ?>
I hope that helps someone!
Cheers!

I did this and it worked for me. Copy /app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml and put it in your /app/design/frontend/default/[your template]/template/catalog/product/list/ as toolbar_new.phtml .
Create a cms page and add this to the layout update :
<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/ga_gallery.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbarnosort.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
<action method="setCategoryId"><category_id>76</category_id></action>
</block>

Related

List 8 latest products on homepage - Magento 1.9.2.1

I know this question gets asked quite a bit and seems straight forward but I can't seem to find a post which states an answer that works.
There a few with solutions on how to list products marked with a 'new from' date in the backend and there are solutions which list the latest products from a specific category but I just need the 8 most recently added products to the catalog full stop.
Currently I am manually adding the products to a 'latest products' category with an ID of 116
and have this in the content of my home page CMS page:
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="116" template="catalog/product/list-latest.phtml"}}
Then in the list-latest.phtml template file, I have some code to get the collection:
<?php
$_productCollection=$this->getLoadedProductCollection()->setPageSize(10);
$_productCollection->clear(); //this will unset the loaded items.
$_productCollection->getSelect()->limit(10); //set a new limit
$_productCollection->getSelect()->reset(Zend_Db_Select::ORDER); //reset the order
$_productCollection->getSelect()->order('cat_index_position asc');//force order by position in category
$_productCollection->load();
$_helper = $this->helper('catalog/output');
?>
And then it loops through the collection and works fine but I need a way to get the latest products from ALL categories and automatically put the latest 8 products on the homepage.
Is there a way to alter this code to do this?
Please try the following code
Place below code in you home page via admin login cms->select your home page->
design->Layout Update XML
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml" after="cms_page">
<action method="addPriceBlockType">
<type>bundle</type>
<block>bundle/catalog_product_price</block>
<template>bundle/catalog/product/price.phtml</template>
</action>
<action method="setColumnCount"><columns>4</columns></action>
<action method="setProductsCount"><count>8</count></action>
</block>
The above code will show you new product with four columns per row and total 8 product limit.
Let me know if you have any query
I did this using a widget. Create a widget with:
type:Catalog new products list
Display On: where you want it
In the Widget Options tab: Display Type: all products (you can select New Products but then you have to mark products as new rather than the latest you added)
There are other options that are self-explanatory.
You will probably have to theme your widget but it shouldn't be too different to a normal product displays.

Magento 1.7:Show category image on category page in full width in a 2 column template

Can't find a solution for this issue running Magento 1.7. The category shown above in the main column. I want to show it above both columns, on page width. Here is an example: http://www.vimodos.nl/schoenen?art_sex=92
Anyone with a solution?
Your reply is much appreciated!
UPDATE
Thanks for the reply. I followed your instructions and added a block called category.image in the catalog.xml
<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/category_image" name="category.image" template="catalog/category/image.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
After that I created a image.phtml file under /template/catalog/category/
When reloading the category page it's empty, there is no error message. The widgets in the left side bar are visible.
Any suggestions? Many thanks!
This seems to be a built in feature in Magento.
To enable it do the following:
Log in to the admin panel
Go to catalog->manage categories
Select the category you want to add an image
You will see a place where you can add an image (just upload it)
Once you add an image it will automatically show in category page
Update
Here is the code to get the category image:
$category = Mage::getModel('catalog/category')->load($catId);
$category->getImageUrl(); // remember to echo it out
In order to set this up above layered navigation, do the following steps:
Add a block to the catalog.xml (in the: <catalog_category_default translate="label"> section.
Add the code above to the template file (that you referenced in the block above)
Let us know if you need further assistance with this

Magento : show new products on home page

I am working on my first Magento project. I want to display new products to the home page
I have researched and added this code
{{block type="catalog/product_new" column_count="6" products_count="3" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
And it worked until I added products from a category to same home page. Code is
{{block type="catalog/product_list" category_id="8" template="catalog/product/bestlist.phtml"}}
Now it shows products from category but not new products. I have disabled cache and also flushed all the existing cache.
I have tried and checked many ways but coulnt figure it out.
Can some body help me with a solution for this please?
PS: I am using latest version of magento 1.7.X
Thanks in advance,
Kiran
First, go to “CMS” > “Pages” > select “Home Page” (URL Key: home).
Click on “Design”
Paste the following XML update into the field provided:
<reference name="content">
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml" after="cms_page">
<action method="addPriceBlockType"><type>bundle</type><block>bundle/catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action>
<action method="setColumnCount"><columns>4</columns></action>
<action method="setProductsCount"><count>4</count></action>
</block>
</reference>
If you would like to increase/decrease the amount of products per column, please change
<action method="setColumnCount"><columns>4</columns></action>
to
<action method="setColumnCount"><columns>6</columns></action>
Also if you would like to limit the amount of products shown, change
<action method="setProductsCount"><count>4</count></action>
to
<action method="setProductsCount"><count>3</count></action>
Please note: For the products to show on the homepage you MUST ensure you have marked the products as new by setting “Set Product as New from Date” and “Set Product as New to Date” options in the “General” tab.
First, go to “CMS” > “Pages” > select “Home Page” (URL Key: home). Click on “Content” Paste the following Code
{{widget type="catalog/product_widget_new" display_type="new_products" show_pager="1" products_per_page="50" products_count="50" template="catalog/product/widget/new/content/new_grid.phtml"}}
Its working for me;
also we can set product limit on single page.
The code you used is for categories only. If you want to add a new module like new products in your magneto store , you have to search a Magento extension from http://www.magentocommerce.com/magento-connect/

Selective HTML Blocks on Product Pages in Magento?

I want to display specific HTML blocks on all product pages of a specific category in Magento.
For example:
Categories - dress, phone, gps
HTML blocks for these categories: dress.phtml, phone.phtml, gps.phtml
On all the pages of products in dress, dress.phtml is displayed - dress size charts, color charts, how to wash, etc.
On all the pages of products in phone, phone.phtml is displayed - battery care, how we package the phones, etc.
On all the pages of products in gps, gps.phtml is displayed - GPS usage, installation, etc.
You get the idea. How can I do this in Magento? How can I call different PHTML files (dress.phtml, phone.phtml or gps.phtml) in catalog/product/view.phtml by product category?
Thanks!
This is easily achieved by making a few modificaitions to your catalog/product/view.phtml file and your custom theme's layout/local.xml file.
Let's begin by modifying local.xml. Open it up and type / copy & paste the following code:
<catalog_product_view>
<reference name="content">
<reference name="product.info">
<block type="catalog/product_view" name="product.dress" as="productDress" template="wherever/you/keep/dress.phtml" />
<block type="catalog/product_view" name="product.phone" as="productPhone" template="wherever/you/keep/phone.phtml" />
<block type="catalog/product_view" name="product.gps" as="productGps" template="wherever/you/keep/gps.phtml" />
</reference>
</reference>
</catalog_product_view>
What we're essentially doing by modifying local.xml is making your new templates available to the catalog/product/view.phtml file within the product.info block. The block type is *catalog/product_view* so we have access to all the same information and methods available within catalog/product/view.phtml. We can then write a bit of code in view.phtml to decide what block to output
$_currentCategory = Mage::registry('current_category');
if ($_currentCategory->getId() == id of dress category) {
echo $this->getChildHtml('productDress');
} elseif ($_currentCategory->getId() == id of phone category) {
echo $this->getChildHtml('productPhone');
} elseif ($_currentCategory->getId() == id of gps category) {
echo $this->getChildHtml('productGps');
}
All we're doing here is checking the current category of the product and outputting the associated block. Of course you'll need to replace "id of ___ category" with the appropriate category ID value. This won't work if you're in a child category of one of the categories you'd like to find. For example, if your structure is as follows Phone > Accessories > Phone Charger Product we'll only find the latest category (Accessories) in the Phone Charger Product. There's other ways of finding a parent category which are scattered across Google and StackOverflow.
Hope that helps. I don't have means to test this code unfortunately but it should work. Good luck!
$product->getCategoryIds() can give you the category ids to which the product belong.

Display newly added simple attributes in product page and show the selected values in shopping cart (Magento)

I have two variations in my website color and size. I have added it to my "Default Attribute Set" and updated respective color and size for each product.
But now i need to display the color and size option in a drop down box, and when user selects it and adds the product to cart. It should appear in the shopping cart along with product information and in the entire checkout process.
is there any option in backend to enable this? or should i do this by modifying the code?
if i should do it by modify the code, how do i do it?
(I learnt ways to show the attribtues in drop down in product page through the link is it possible to show custom attributes of associated products under a grouped product in front end? (Magento), but not sure with showing them in cart page)
please suggest.
Thanks,
Balan
Add below code in your catalog/product/view.phtml page.That will bring the custom options to your product page.
if ($_product->isSaleable() && $this->hasOptions()):
echo $this->getChildChildHtml('container1', '', true, true)
endif;
if ($_product->isSaleable() && $this->hasOptions()):
echo $this->getChildChildHtml('container2', '', true, true)
endif;
Shopping cart
check you checkout.xml for addItemRender methods are added or not in checkout.cart block.
<checkout_cart_index translate="label">
<reference name="content">
<block type="checkout/cart" name="checkout.cart">
....
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/item/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/item/default.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/item/default.phtml</template></action>
...
</block>
</reference>
and check template files is it called correctly or not.
Check with magento default is your blocks are called correctly in cart.phtml and other pages
balanv,
Use "Configurable" products.
It will provide you dropdown with colors on product page
And will display selected colors in checkout cart.
Read magento wiki for more details ;)

Resources