Get the tier prices of associated product in Magento 1.8.0 - magento

I'm using Magento 1.8.0
How can I get the tier prices of the associated product?
I'm only getting the price of the configurable product. Below is my site example:
Example: Product Apple is a configurable product thas has tier prices, $10,$20,$30. Product Apple has also an associated product like Green Apple, it has tier prices, $15,$20,$30.
My question here, is how can I get the value of my Associated products.
Thanks and Have a good Day!

You have to firstly get associated products
$product = Mage::getModel('catalog/product')->load(1); //your_product_id
$childProducts = Mage::getModel('catalog/product_type_configurable')
->getUsedProducts(null,$product);
foreach($childProducts as $child) {
$id = $child->getId();
$pro = Mage::getModel('catalog/product')->load($id); //load associated product id
if($pro['tier_price'] != NULL) {
foreach($pro['tier_price'] as $tier){
echo $tier['price'].'<br/>';
}
}
}

Related

Upsell : get parent product from child product id

i am looking for code which can help me get parent product id from child product Id and this both products are related using upsell feature
so far i was able to retrieve child products id from parent id by using below code
//Get product detail using product id (Suppose you have product id is : $product_id)
$_product = Mage::getModel('catalog/product')->load($product_id);
// Fetch list of upsell product using query.
$upsell_product = $_product->getUpSellProductCollection();
but i want result in reverse manner
$childProductId = 17;//edit this value, or get it by $product->getId()
$productsLinkedAsUpsell = Mage::getModel('catalog/product_link')->getCollection()
->addFieldToFilter('linked_product_id', $childProductId)
->addFieldToFilter('link_type_id', Mage_Catalog_Model_Product_Link::LINK_TYPE_UPSELL);
foreach ($productsLinkedAsUpsell as $upsell) {
$parentId = $upsell->getProductId();
}

Magento - How to check if Cross Sell products exist.

In view.phtml I want to check if the product has any cross sell products associated with it.
I've done the same with related products:
$relatedProductsId=$_product->getRelatedProductIds();
$relatedProducts=array();
$i=0;
foreach($relatedProductsId as $relatedProductId)
{
$relatedProducts[$i] = array(Mage::getModel('catalog/product')- >load($relatedProductId)->getProductUrl(),
Mage::getModel('catalog/product')->load($relatedProductId)->getName(),
Mage::getModel('catalog/product')->load($relatedProductId)->getImageUrl(),
Mage::getModel('catalog/product')->load($relatedProductId)->getFormat()
);
$i++;
}
I'm not sure what the function used is for the Cross Sells products.
Please can someone help.
Did you try
$crossSellProducts = $_product->getCrossSellProducts()
?
It will return an array of cross-sell product objects.

Magento - Get Product SKU's and quantities on order

I have created an event observer on the "sales_order_place_after" event, which fires when the user places an order in Magento's checkout. That event triggers my observer, which needs to get the following information, which is then sent to an external inventory management system.
Information needed: The SKU and quantity of every product on the order
I have included part of my observer model below. I am accessing the order object. I can get all the items in the order, but how do I get the SKU for every product that makes up the order. For example, with a simple product, this is very easy. However, with a bundled or configurable product I do not know how to access the children that make up that bundled product with their SKU's and quantities. That is the info I need for both bundled and configurable products. I need the SKU and quantities of the children that were selected. For the life of me, I can't figure out what method to call to access that information. I wish there was something like: $item->getBundleChildrenSkuQuantity();
$order = $observer->getEvent()->getOrder();
$joomecomPacket = array();
if ($order->getTotalItemCount() > 0) {
$items = $order->getAllItems();
foreach ($items as $item) {
$productType = $item->getProductType();
switch ($productType) {
case 'bundle':
break;
case 'configurable':
default: // simple products
if (isset($joomecomPacket[$item['sku']])) {
$joomecomPacket[$item['sku']] += $item['qty_ordered'];
} else {
$joomecomPacket[$item['sku']] = $item['qty_ordered'];
}
break;
}
}
}
You're missing a break after your configurable case. The default case is executing for configurable products.
Try this:
$items = $order->getAllVisibleItems(); // gives only parent items
foreach ($items as $item){
$childItem = $item->getChildren(); //do something with $cildItem like $childItem->getSku() etc...
}

Manual magento order creation - item price original and converted to store currency

I'm using code below to create order in magento:
$quote = Mage::getModel('sales/quote');
$quote->setCheckoutMethod('guest')->save();
$quote->setStore($store);
$quote->setForcedCurrency(Mage::getModel('directory/currency')->load($storeCurrency));
foreach ($productInCardList as $productItem) {
$product = Mage::getModel('catalog/product')->load($productItem['id']);
$product->setPrice($productItem['price']);
$request = new Varien_Object();
$request->setQty($productItem['qty']);
$quote->addProduct($product, $request);
}
$quote->collectTotals();
$quote->reserveOrderId();
$quote->save();
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$orderObj = $service->getOrder();
// ... code setting billing, shipping address, payment and shipping method.
The order is created, but it shown in sales->orders grid with incorrect G.T. Purchased Price (the amount for USD and EUR are the same)
The orders placed thorugh magento front end have correct G.T. Purchased price the initial price in USD (92 USD) and converted price for store in EUR(66 EUR). But orders which is created using code shows the same amount converted in EUR(66 EUR) and USD (66 USD). I would very appreciate if you help me to make the price shown correctly in the order.
Thank you for your help
To convert a price from currency of store view in which the order is placed to the base currency (which Magento is setup with and is shown in the admin), use the following code:
$basePrice = Mage::app()->getStore()->convertPrice($price, false, false);

Magento: Get product price from another store?

I have multi-store Magento installation, and different product prices are set in different stores. I want to display on one page the actual product price from the current store, and the price from other store (I have its ID), but I'm not sure how to get that info?
The prices are set for each store view for each product, no tier-pricing or special-pricing was used.
If you know the storeId, set in setStoreId :
/**
* call the Magento catalog/product model
* set the current store ID
* load the product
*/
$product = Mage::getModel('catalog/product')
->setStoreId($storeId)
->load($key);
Display in a block :
echo $product->getName();
We can also use print_r to see the values :
print_r($product->getData());
The following code will show current store ID :
$storeId    = Mage::app()->getStore()->getId();
To get all product ID's with each store view :
$product    = Mage::getModel('catalog/product');
$products   = $product->getCollection()->addStoreFilter($storeId)->getData();
If you change the $storeId will show different product.

Resources