Magento: price on cart is from configurable product, not from simple-product - magento

I had a similar problem last time, but the solution just helps with my test-product, whre I can add price +/- in my configurable product. Price in Cart is not correct Magento 1.8
Is it possible to take the price of the simple product, without adding some prices +/- at the configurable one?
On cart I get the SKU of the simple-product, but with $_item->getPrice() I only get the Price of the configurable product.
Thanks for help!

Use the sku of the item to load the simple product, for example:
$_productSku = $_item->getSku();
$_product = Mage::getModel('catalog/product');
$_productId = $_product->getIdBySku($_productSku);
$_product->load($_productId);
then use
$_product->getPrice();
Regards
Hans

Shorter solution is:
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku());
$_product->getPrice();

Related

Display the product price without tax and tax of single product in Magento

I would like to display the product price without tax and the tax amount of a single product from a order in Magento.
I have the item already loaded:
$qty =$item->getData('qty_ordered');
$sku =$item->getSku();
$name =$item->getName();
$tax =$item->getTaxAmount()/$qty;
$price_incl_tax =$item->getPriceInclTax();
$price_excl_tax =$price_incl_tax-$tax;
This is working but I don't think this is a good solution. Is there a easier way without calculating the price in PHP by myself?
Thanks in advance!
Edit: I need this:
$_product = $item->getProduct();
$finalPriceExcludingTax =
Mage::helper('tax') ->getPrice($_product, $_product->getFinalPrice(), false );
usable on ordered items, with the price the customers has payed.
try to use tax helper:
$_product = $item->getProduct()
$finalPriceExcludingTax = $this->helper('tax')
->getPrice($_product, $_product->getFinalPrice(), false );

magento i need to apply discount 20% for the total if above 50euros but not to the discounted items

magento i need to apply discount 20% for the total if above 50euros but not to the discounted items if customers selects some already discounted items that should not include in the total can any one help
Thanks in advance
You need to create a custom module or say shopping cart price rule and an event observer to check whether the "special price" is zero or not. If it is "Zero" that means it is not a already discounted product or you can even check the "final price" with the "price" , if the final price is lesser than price it is already discounted.
If these conditions are satisfied get the prices of remaining products prices and discount them then add the already discounted products price to make the total amount.
I hope You understood this concept and write your own module.
you have to use a check in view page.
for example
$price = $product->getPrice();
$specialprice = $product->getFinalPrice();
if(!empty($specialprice)){
//then your price would be same
}
elseif(empty($specialprice)){
then price would be = $price*20/100;
}
hope this would help you and don't forget to like if it was helpful

How to show sort by most popular(most sold) products on product listing page in Magento?

I am using following tutorial to display the most sold product sort by option(Filtering) to display on product listing page in magento?
Tutorial
/app/code/local/Mage/Catalog/Model/Resource/Product/collection.php
<?php
public function sortByReview($dir){
$table = $this->getTable('review/review');
$entity_code_id = Mage::getModel('review/review')->getEntityIdByCode(Mage_Rating_Model_Rating::ENTITY_PRODUCT_CODE);
$cond = $this->getConnection()->quoteInto('t2.entity_pk_value = e.entity_id and ','').$this->getConnection()->quoteInto('t2.entity_id = ? ',$entity_code_id);
$this->getSelect()->joinLeft(array('t2'=>$table), $cond,array('review' => new Zend_Db_Expr('count(review_id)')))
->group('e.entity_id')->order("review $dir");
}
?>
But I want to sort products which are most sold from every category.
How can I do this?
Is there any free extension available for this?
I did the following thing as the client did not want automatically filter most sold product.
I created an attribute "popular" as drop down and give values from 1 to 5.Then marked "Used for Sorting in Product Listing" to Yes.
After this the attribute was visible under sorting options.

Add additional product price with mangento base product price

I want to add additional price with product(simple) price, I am trying to do this with the help of custom attributes. I add a custom attribute "Margin Price" and I want to add up this custom attribute value (margin price) with the base price of the product in the template file.
I am updating all product price after each 5 minutes by cron job, thats why I think I have to do add margin price with base product price by this way.
I added it successfully in product list page and in product view page, but have problem with how to add this margin price with base price in the cart and onepage checkout?
Here is the code on the product list page and same for the product detail page which works fine for me in magento 1.6.x.
$regularPrice = number_format($_product->getFinalPrice(), 2);
//echo $regularPrice = $this->getPriceHtml($_product, true
$priceWithoutComma = str_replace(",", "",$regularPrice);
settype($priceWithoutComma, "float");
$marPrice = $_product->getMarginPrice();
settype($marPrice, "integer");
$finalPrice = $priceWithoutComma + $marPrice;
echo $finalPrice.Mage::app()->getLocale()->currency(Mage::app()->getStore()->
getCurrentCurrencyCode())->getSymbol();
I am doing this right way or I have to changes the whole process?
Looks like you might need to consider a different approach. The reason being that echoing the price from a template file does not modify the price of the item in any way. It simply outputs a calculation.
You'll need to learn a bit about event listeners for this one to work.
Here's a blog post of mine on how to do this.

Magento: Getting Discounted price

We have a mixture of products, some with specialPrice and some with Catalog Rules set.
I need to display the discounted % for all my products on my frontend.
We were using $_product->getSpecialPrice() to get the discounted price, but this fails for products which prices based on catalog rules.
Is it possible to get the Discounted prices based on the catalog rule or from the specialPrice ?
Yes you can use $_product->getFinalPrice().
Here is the difference in the three prices:
$regularPrice = number_format($_product->getPrice(), 2);
$discountedPrice = number_format($_product->getFinalPrice(), 2);
$specialPrice = number_format($_product->getSpecialPrice(), 2);
Try this snippet:
This one will calculate price rules.
Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice());
Is is what you looking for?

Resources