Inserting fields in the Invoice History Magento - magento

I managed to enter the invoice_totals block, however my goal is to insert the block "Invoice History", follow the example:
The code for this:
<adminhtml_sales_order_invoice_new>
<reference name="invoice_totals">
<block type="adminhtml/sales_order_totals_item" name="teste" template="module/name/sales/order/view/nota_fiscal.phtml" />
</reference>
</adminhtml_sales_order_invoice_new>
I need add this same field, but in Invoice History, like this:
This to create a new invoice, Thanks for help.

try with this code :
<adminhtml_sales_order_invoice_addcomment>
<block type="adminhtml/sales_order_comments_view" name="test" template="module/name/sales/order/view/nota_fiscal.phtml"></block>
</adminhtml_sales_order_invoice_addcomment>

Related

Magento 1.9.2.1: Color, size attribute of product not showing on onepage checkout

Recently I have added attributes to the product color and size. (configurable products)
When we add to cart, and go to view cart then we see the products with attributes color and size.
I added shopping cart block in onepage checkout in app/design/frontend/smartwave/porto/layout/iwd_opc.xml
<reference name="content">
<block type="checkout/cart" name="checkout.cart" template="checkout/cart.phtml">
<block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
<block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
<block type="checkout/cart_sidebar" name="checkout.cart.sidebar" as="sidebar" template="checkout/cart/sidebar.phtml"/>
</block>
</reference>
I get the following page after adding shopping cart layout to onepage cart
Now I am stuck here, how should I get the attributes name here?
I have set attributes to be visible on frontend from backend as well.
Code to display products in the cart is on app/design/frontend/smartwave/porto/template/checkout/cart.phtml
<?php foreach($this->getItems() as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php endforeach ?>
Logic of the code is written over here: app/code/core/Mage/Checkout/Block
public function getItems()
{
if ($this->getCustomItems()) {
return $this->getCustomItems();
}
return parent::getItems();
}
Another way of displaying the products to the cart is: But I dont want to use this code to display the list in the cart:
$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
$productName = $item->getProduct()->getName();
$productPrice = $item->getProduct()->getPrice();
echo "Name: ".$productName." Price: ".$productPrice;
}
I have also tried to add attributes in xml file
app/code/core/Mage/Sales/etc/config.xml
<item>
<product_attributes>
<color/>
<size/>
<condition/>
<sku/>
<type_id/>
<name/>
<status/>
<visibility/>
<price/>
<weight/>
<url_path/>
<url_key/>
<thumbnail/>
<small_image/>
<tax_class_id/>
<special_from_date/>
<special_to_date/>
<special_price/>
<cost/>
<is_recurring/>
<recurring_profile/>
<gift_message_available/>
<msrp_enabled/>
<msrp/>
<msrp_display_actual_price_type/>
</product_attributes>
</item>
So I have just copied the block to the onepage checkout page, but I am not able to understand that why the onepage checkout page is not showing product's size and color ("/onepage/") and it is strange that color and sizes can be seen on checkout page ("checkout/cart/")
Thanks in advance
I believe you have not added itemrendere in your layout. Basically cart items are listed using checkout/cart/item/default.phtml.
I will suggest to look over checkout.xml layout file and copy the whole layout <reference name="content"> node into your iwd and then start removing the template includes which you do not require.
Another method is using layout updates which will extend your iwd layout to checkout_cart. Which will do same thing above. You need to use <remove name=""> tag to remove extra cart includes from your iwd handle.
Finally I found the solution with the help of Blastfreak
Include following lines in app/design/frontend/smartwave/porto/layout/iwd_opc.xml
<reference name="content">
<block type="checkout/cart" name="checkout.cart" template="checkout/cart.phtml">
<block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
<block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
<block type="checkout/cart_sidebar" name="checkout.cart.sidebar" as="sidebar" template="checkout/cart/sidebar.phtml"/>
<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>
Output page:

magento layered navigation on home page - filtered items have wrong urls, causes 404

After a lot of searching, I finally found a solution to add Layered navigation to the Magento Home Page. At first glance, it was working properly with filtered results as expected.
However, there is a catch as the URLs for the filtered results all have an added 'root-catalog' in their urls. This causes a 404 - however, if I take out the 'root-catalog' the urls are working fine.
What am I missing? Please help!
Help is appreciated in advance!
Code to add layered navigation to home page:
<reference name="left">
<block type="catalog/navigation" name="catalog.cat.leftnav" before="sidenav.left" template="catalog/navigation/left.phtml"/>
<block type="catalog/layer_view" name="catalog.leftnav" after="catalog.cat.leftnav" template="catalog/layer/view.phtml"/>
<action method="unsetChild"><alias>right.reports.product.viewed</alias></action>
<action method="unsetChild"><alias>right.reports.product.compared</alias></action>
</reference>
<reference name="content">
<block type="catalog/product_list" name="product_home" template="catalog/product/list.phtml">
<action method="setCategoryId">[b]<category_id>3</category_id>[/b]</action>
<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" />
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</reference>
Layered navigation needs a category on which to base to get products, sub categories on which to filter, etc. On the homepage then, it takes the root category by default, and the corresponding product collection acts like it would do on other "common" category pages : it uses URL rewrites linking to the current category.
To prevent current category to be used in product URL, you can rewrite the layer model by copying the file app/code/core/Mage/Catalog/Model/Layer.php to app/code/local/Mage/Catalog/Model/, and changing the prepareProductCollection($collection) in it with something like this :
public function prepareProductCollection($collection)
{
$collection
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addMinimalPrice()
->addFinalPrice()
->addTaxPercents();
if ($this->getCurrentCategory()->getId() == $this->getCurrentStore()->getRootCategoryId()) {
$collection->addUrlRewrite(0);
} else {
$collection->addUrlRewrite($this->getCurrentCategory()->getId());
}
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
return $this;
}

Pager toolbar in custom module in magento

I use this tutorial and display products on the basis of multiple categories but now I am getting in issue is that the pager tool bar not working on that.
My block code is :
<reference name="content">
<block name="mymodule" type="mymodule/product_listcategories" template="catalog/product/list.phtml">
<action method="setCategories">
<ids>2,3,4</ids>
</action>
</block>
</reference>
I also add this code with above
<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"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
It display toolbar but the toolbar is not working (limit,orderby).
My block code is
class Mymodule_Block_Product_Listcategories extends Mage_Catalog_Block_Product_List
{
protected function _getProductCollection()
{
$this->_productCollection = Mage::getModel('catalog/product')->getCollection();
$this->_productCollection->addAttributeToSelect('*');
if($this->getCategories()!="")
$this->_productCollection->addCategoriesFilter($this->getCategories());
return $this->_productCollection;
}
}
}
Does anyone know where is the problem? I think I'm missing some code for the pager? Thanks in advance
After search so much i got a solution.I didn't know whether it right or wrong way but it solve my problem.On my block i create intance of
$cpBlock = $this->getLayout()->getBlockSingleton('Mage_Catalog_Block_Product_List_Toolbar');
and access the pager core function like $this->_itemPerPage = $cpBlock->getLimit(); .In the above code itemperpage is the total no of items to be displayed on listing page.This code work if you create custom module and extend you block from list block.Thanks

Unable to prevent Magento from Caching a Block

I'm working on a Magento 1.6 site, which has the following xml inside the home page's CMS "Layout Update XML" field:
<reference name="content">
<block type="catalog/navigation" name="catalog.category.home" as="homecategory" template="catalog/category/homecategory.phtml" />
</reference>
As the template shows randomized categories, I would like to disable caching for this block.
To do so, I attempted using getChildHtml('sub-block-template', false) with the following:
(homecategory has $this->getChildHtml('random_categories', false) in its template)
<reference name="content">
<block type="catalog/navigation" name="catalog.category.home" as="homecategory" useCache="false" template="catalog/category/homecategory.phtml">
<block type="catalog/navigation" name="catalog.category.home.randcats" as="random_categories" useCache="false" template="catalog/category/random.phtml" />
</block>
</reference>
So now I'm stuck, wondering why I can't prevent caching of that block, despite using the 'false' argument.
I had this same problem. I beleive it has to do something with the block type of type="catalog/navigation". I've seen this disabling of caching work on other types of blocks. Here is a fix for this block type and this problem:
phtml file change: make sure the second param is false
echo $this->getChildHtml('topCategoriesList',false);
xml file change:
Add these actions to the block
<block type="catalog/navigation" name="topCategoriesList" as="topCategoriesList" template="catalog/navigation/categorylist.phtml">
<action method="unsetData"><key>cache_lifetime</key></action>
<action method="unsetData"><key>cache_tags</key></action>
</block>
Have you tried forcing it by creating a new custom block type and overloading the caching functions? Extend the Mage_Catalog_Block_Product_List_Random class and create an empty pseudo-constructor:
protected function _construct() {}
This will prevent inheriting adding cache tags, lifetime, and other metadata to the block object. Then you can overload the cache key info as well so that it doesn't use any existing (or enabled) cache blocks. For example:
public function getCacheKeyInfo()
{
return array(
'MY_CACHE_TAG',
Mage::app()->getStore()->getId(),
(int)Mage::app()->getStore()->isCurrentlySecure(),
Mage::getDesign()->getPackageName(),
Mage::getDesign()->getTheme('template')
);
}

Add a link to Magento's My Account Page Conditionally

I would like to create a link on the My Account page that only get displays under certain conditions.
Right now I have the link display all the time by adding the following entry to my layout XML file:
<customer_account>
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="nie"><name>nie</name><path>nie</path><label>NIE Admin</label></action>
</reference>
</customer_account>
I am assuming there is a way to code this so that it only displays under certain circumstances.
The cart & checkout links already do something similar so their method can be copied.
Create a block. It won't be displaying directly so can be descended from the boring Mage_Core_Block_Abstract.
Give it a method where the conditional logic will go.
public function addNieLink()
{
if (($parentBlock = $this->getParentBlock()) && (CONDITION-GOES-HERE)) {
$parentBlock->addLink($this->_('NIE Admin'), 'nie', $this->_('NIE Admin'), true, array(), 50, null, 'class="top-link-cart"');
// see Mage_Page_Block_Template_Links::addLink()
}
}
protected function _prepareLayout()
{
// Add the special link automatically
$this->addNieLink();
return parent::_prepareLayout();
}
Put your check in place of CONDITION-GOES-HERE.
Add your block to the links block.
<customer_account>
<reference name="customer_account_navigation">
<block type="yourmodule/link" name="yourmodule.link" />
</reference>
</customer_account>
(Correct the block type here to your newly created link block)
The important bit is it calls getParentBlock() to find out where the link is to go.

Resources