can anyone help me in placing the vat/tax number on the pdf invoice in Magento?
I tried this code but it didn't work:
$taxvat = $order->getData('customer_taxvat');
$page->drawText('Tax/Vat: '.$taxvat, 35, 567);
You can retrieve this by doing;
$order->getCustomerTaxvat()
If this value is empty you could try this;
$customer = Mage::getModel('customer/customer')->load($order->getData('customer_id'));
$taxVat = $customer->getData('taxvat');
Related
I am trying to display all products on my website in every category by descending SKU #'s. Can't seem to figure out how to do this, any ideas?
The following snippet will give you the collection you want, you may need to add pagination yourself if necessary.
$collection = Mage::getModel("catalog/product")->getCollection();
$collection->setOrder('sku', 'DESC');
You'll also need to join on any extra attributes with joinAttribute(), since the catalog_product database storage follows the EAV pattern.
I think this should help. Go to Admin->Catalog->Attributes->Manage Attributes find SKU and enable SKU first. Then you have to go app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php. Find at line 119 and change
protected $_direction = 'asc';
Change to
protected $_direction = 'desc';
I need to add product reviews to the list view of the category page, not just the summary rating. Need to add the “Detailed star rating”, “Summary of review”, “Nickname” and “Body of review”. Much the same as you would see it on the product review page.
I’ve had a look at the base Magento template file for the product review page app/design/frontend/base/default/review/product/view/list.phtml. There is an array $_items = $this->getReviewsCollection()->getItems(); that contains all the review info that I need.
However if I try to use $_items = $this->getReviewsCollection()->getItems(); in the category template file app/design/frontend/default/my_theme/template/catalog/product/list.phtml I get the following error
“Fatal error: Call to a member function getItems() on a non-object”.
How do I get past this error, or am I going about this the wrong way? Any advice or tips would be appreciated.
Hello you will use below code may be help you.
$entity_ids = array(22, 23);
$reviewcollection = Mage::getModel('review/review')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->addFieldToFilter('entity_id', Mage_Review_Model_Review::ENTITY_PRODUCT)
->addFieldToFilter('entity_pk_value', array('in' => $entity_ids))
->setDateOrder()
->addRateVotes();
$_items = $reviewcollection->getItems();
Hi can anybody tell me how can i get after successfully order is placed shipping method title?
Here is what i have
$iOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$oOrder = Mage::getModel('sales/order')->loadByIncrementId($iOrderId);
echo $oOrder->getShippingMethod();
but how can i get this shipping method title?
$oOrder->getShippingDescription();
$order = Mage::getModel('sales/order')->loadByIncrementId($iOrderId);
$order->getShippingDescription();
Or
$shipping = $order->getShippingAddress()->getShippingMethod();
echo $shipping->getData('title');
This worked for me when looking for the custom title:
Mage::getModel('sales/order')->loadByIncrementId($orderId)->getTracksCollection()->getFirstItem()->getTitle();
$order->getShippingDescription(); // returns Shipping Method Title
I need some basic information on my Magento checkout success page to check some conversions through my shop. For that I need the total price of the order and all article IDs.
While searching I found a code to get the last order:
<?php
$_customerId = Mage::getSingleton('customer/session')->getCustomerId();
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($lastOrderId);
?>
But how can I get the total price and all article IDs (seperated by ,).
I'm quiet new to Magento, so everything is a bit confusing to me.
Can somebody help me?
Thank you.
Greetings from Germany,
Raisis
You can get order total by $order->getData('base_grand_total');
in order to get all articles (loop through) you need to do,
foreach($order->getAllItems() as $items) {
$items->getName();
}
Use this code to get order object and order total, it's cleaner
<?php
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$total = $order->getGrandTotal();
?>
I need a way to retrieve product IDs associated with a Catalog Price Rule promotion (ex. 50% the price of all items in the BICYCLES category). I'd like to do this without having to iterate through the entire product database.
I know there is a function called getRuleProductIds($ruleID), which should return an array of product IDs by rule ID, but I have no idea where to use it, which collection to associate it with, etc.
I have the following code in a products_in_promotion.phtml template:
<?php
$rules = Mage::getModel('catalogrule/rule');
$collection = $rules->getCollection();
$sale_items = $collection->getRuleProductIds(1); # ??????? this throws an error
?>
$collection properly stores an array of all the Catalog Price rules, but that's as close as I can get. No product list is in sight.
Any ideas what I'm doing wrong here?
You don't have to get it as a collection. Just load the rule that you want and use getMatchingProductIds as found in Mage_CatalogRule_Model_Rule (aka catalogrule/rule).
$catalog_rule = Mage::getModel('catalogrule/rule')->load(1); // Rule ID
$skus = $catalog_rule->getMatchingProductIds();
var_dump($skus);
hth
If you have many products in your store then this is the efficient way. You may add website_id, custom_group_id in where class to be more specific.
$resource = Mage::getSingleton('core/resource');
$connection = $resource->getConnection('core_read');
$tableName = $resource->getTableName('catalogrule_product');
$productIdList = $connection->fetchAll('SELECT product_id as product_id FROM '.$tableName.' WHERE rule_id = 1);
It worked for me after adding website filter to the code suggested by seanbreeden.
$catalog_rule = Mage::getModel('catalogrule/rule')->load(1); // Rule ID
$catalog_rule->addWebsiteFilter('1');
$skus = $catalog_rule->getMatchingProductIds();
var_dump($skus);