To add product grid in custom module admin form - magento

I have created custom module in magento. Its working good. But now my problem is, I want to add product grid to my product list tab.I have found the solution through this link.I have created new tab.But when i load that tab, its shows me an error like
Fatal error: Call to a member function setProdlist() on a non-object in /home/trendyc/public_html/app/code/community/Whole/Cate/controllers/Adminhtml/WhcatalogController.php on line 64
Mycontroller file's productsAction code here
$this->getLayout()->getBlock('products.grid')
->setProdlist($this->getRequest()->getPost('products_prodlist', null));
I think, i need to do some modification on layout file. But i can't get what modifications need to do there in layout .xml file.I hope you understand my problem. Please help me guys!

You should create xml for your extension, for ex. design/adminhtml/default/default/layout/my_ext.xml and describe your block product.list
<ext_adminhtml_item_products>
<block type="core/text_list" name="root" output="toHtml">
<block type="ext/adminhtml_item_edit_tab_products" name="products.grid"/>
<block type="adminhtml/widget_grid_serializer" name="products_grid_serializer">
<reference name="products_grid_serializer">
<action method="initSerializerBlock">
<grid_block_name>products.grid</grid_block_name>
<data_callback>getSelectedProducts</data_callback>
<hidden_input_name>links[prodlist]</hidden_input_name>
<reload_param_name>products_prodlist</reload_param_name>
</action>
</reference>
</block>
</block>
</ext_adminhtml_item_products>

you can use this on cms page:
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}
or in phtml use this to display products:
$this->getLayout() ->getBlockSingleton('ccatalog/product_list')->setTemplate('catalog/product/list.phtml')->toHtml();

Related

get error messages in content area on cart page Magento

HI i have made a module in which i have a controller which adds product to the cart through url . I have add a error messages from controller if the product is not valid.
The problem is the error message is shown above the content area .I need to show those in the content area.I have also tried to add these blocks in
checkout.xml in content area
<reference name="content">
<block type="checkout/cart" name="checkout.cart">
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
but still it not loads the messages in the content area and show above the content area. Can you please suggest me how can i do this.
What are you using to generate these errors - default magento handlers? they generate errors just above the breadcrumb area.
One option would be to give it a id/class and manipulate through javascript.
OR,
Generate custom errors.
You can either unset/re-add blocks as needed with the following methods:
<action method="unsetChild"><name>global_notices</name></action>
<action method="unsetChild"><name>global_messages</name></action>
<action method="unsetChild"><name>messages</name></action>
<block type="page/html_notices" name="global_notices" as="global_notices" template="page/html/notices.phtml" />
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
If adding these as needed using template hints to confirm does not work, find the following line in
app\design\frontend\base\default\template\checkout\cart.phtml
<?php echo $this->getMessagesBlock()->toHtml() ?>
And comment it out/move it to where you wish to render it.

how to display recently viewed products list on product details page - magento

I have used mobileshoppe theme for magento and trying to display recently viewed product list at product details page but some how its not working...
Added code below at catalog.xml
<catalog_product_view translate="label">
<reference name="content">
<block type="reports/product_viewed" name="product.recently.viewed" as="product_recently_viewed" template="reports/product_viewed.phtml"/>
</reference>
</catalog_product_view>
and below code at app\design\frontend\default\mobileshoppe\template\catalog\product\ view.phtml
<?php echo $this->getChildHtml('product_recently_viewed') ?>
I have tried the same with default theme and its also not working, can any one help me to figure out this issue ?
Thanks...
On the the product detail template (view.phtml) you have to be more specific in the xml where you want to place the block. See the example below using local.xml in the theme layout directory (app/design/frontend/your package/your theme/layout/local.xml) to insert the block. Here's an example from a site I'm working on. Ironically we are having problems with it displaying consistently, which I'm trying to figure out right now, but this is working most of the time! Try getting more specific in your catalog.xml and it should work. The xml is in local.xml, the echo is in catalog/product/view.phtml
<?php echo $this->getChildHtml('recently_viewed') ?>
<catalog_product_view>
<reference name="content">
<reference name="product.info">
<block type="reports/product_viewed" name="left.reports.product.viewed" template="reports/product_viewed.phtml" as="recently_viewed" />
</reference>
</reference>
Can you please replace xml reference content to left.
Instead of this
<reference name="content">
Use below and check
<reference name="left">
As it is a part of sidebar so it should work with left / right column as you want to display in page.
Cheers!

Updating custom block in CMS page

I'm having a bit of trouble understanding how to update a custom block that I include in a CMS page.
I am using the standard shortcode in the CMS page, which works fine:
{{block type="catalog/product_list" category_id="16"
template="catalog/product/slider_list.phtml"}}
I am trying to set the column count of this custom custom block, for which I've found that I need something like the following piece of code:
<block type="catalog/product_list" name="catalog.product.slider_list"
template="catalog/product/slider_list.phtml">
<action method="setColumnCount"><columns>4</columns></action>
</block>
I'm not exactly sure under which <reference /> block I should place the code... I looked in catalog.xml, and if I try to place it between <reference name="root" />, I do not get the correct behavior.
Thank you.
Edit: use of incorrect terminology; I was calling the block static, where in fact it is a custom block.
if you want to call it on home page where the reference name should be like in your local.xml or any of the xml of your extension. just add it like below
<cms_index_index>
<reference name="content">
// your custom block
<block type="catalog/product_list" name="catalog.product.slider_list"
template="catalog/product/slider_list.phtml">
<action method="setColumnCount"><columns>4</columns></action>
</block>
</reference>
</cms_index_index>
hope this will sure help you.

Magento: Change the block template in local.xml

I would like the product reviews page to use a different template instead of:
catalog/product/view.phtml
In review.xml, I see the file being called:
<block type="review/product_view" name="product.info" template="catalog/product/view.phtml">
Is there a way I can override that in local.xml and create a new file (ex: view2.phtml) and use that for this page?
<review_product_list>
<reference name="product.info">
<action method="setTemplate"><template>catalog/product/view2.phtml</template></action>
</reference>
</review_product_list>
Yes, you can definitely do that by writing the following code in local.xml:-
<reference name="product.info">
<action method="setTemplate"><template>catalog/product/view2.phtml</template></action>
</reference>
Here view2.phtml is your new file in the proper folder structure.
Hope it helps.

how can i show prodcts by their attribute in product details page in magento

In my site home page, I have three blocks like Recommend product,Top ten product and Talking about product, All products are coming properly by their attribute name.For this, I create three attribute in admin section and add layout design in home page in admin section and add block type in page.xml and i call this blocks by their name in 2column-left.phtml
echo $this->getChilidHtml("block_names")
But,My problem is when i click on any product it will redirect to product details page that is catlog/product/view.phtml, on this page i want to add two different blocks as like home page ,I found its xml page also , I think that is catalog.xml on this page make changes in side the content reference and it is coming ,but i want to add a new block as line content , i was trying but i am not getting any idea please any solution for this.
<catalog_category_layered>
<reference name="recommend">
<block type="catalog/product_list" name="catalog.product_list" as="recommend_list" template="catalog/product/view/recommend.phtml">
</block>
</reference>
</catalog_category_layered>
I add above line code in catalog.xml as a new block and call it in view.phtml as echo $this->getChildHtml('recommend') but it is not showing,I am sure this approach is wrong one .
any solution for this how can i call.
Thanks & Regards
Try this,In your catalog.xml
<catalog_product_view translate="label">// find this line
<reference name="content">
..............
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="catalog/product_list" name="catalog.product_list" as="recommend_list" template="catalog/product/view/recommend.phtml"/> //add your block into product.info block
.............
</block>
</reference>
................
</catalog_product_view>
call the your block using name in in catalog/product/view.phtml
echo $this->getChildHtml('recommend_list')
Hope this helps

Resources