Get configuration sku simple ID or SKU

I'm trying to get the parent configurable product SKU from one of its subsidiaries ID or SKU simple products. I understand that downtime can belong to several configurators, but I want to be specific custom client added to your cart. I read a related question , but he gets all the parent configuration.

I am using Magento EE 1.12

EDIT: Learn more about what I'm doing. When a client successfully checks, I'm trying to get SKU simple and customizable client.

The attempt to apply the code to:

app/design/frontend/enterprise/mytheme/template/checkout/success.phtml 
+6
source share
3 answers

If configurable in the cart already, I think you can interrogate the cart to find a custom and simple identifier.

 $myTargetSimpleProductId = $someIdThatYouKnow; $quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item){ if ($option = $item->getOptionByCode('simple_product')) { $productIdArray[] = $option->getProduct()->getId(); //for the record if ($option->getProduct()->getId()==$myTargetSimpleProductId ){ $myMatchingConfigurableProductId = $item->getProductId(); //capture the ID of the configurable } } } //$productIdArray holds a list of all the IDs of simple products that are in the basket due to configurables. echo("The answer is ".$myMatchingConfigurableProductId); checkout / session') -> getQuote (); $myTargetSimpleProductId = $someIdThatYouKnow; $quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item){ if ($option = $item->getOptionByCode('simple_product')) { $productIdArray[] = $option->getProduct()->getId(); //for the record if ($option->getProduct()->getId()==$myTargetSimpleProductId ){ $myMatchingConfigurableProductId = $item->getProductId(); //capture the ID of the configurable } } } //$productIdArray holds a list of all the IDs of simple products that are in the basket due to configurables. echo("The answer is ".$myMatchingConfigurableProductId); ); $myTargetSimpleProductId = $someIdThatYouKnow; $quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item){ if ($option = $item->getOptionByCode('simple_product')) { $productIdArray[] = $option->getProduct()->getId(); //for the record if ($option->getProduct()->getId()==$myTargetSimpleProductId ){ $myMatchingConfigurableProductId = $item->getProductId(); //capture the ID of the configurable } } } //$productIdArray holds a list of all the IDs of simple products that are in the basket due to configurables. echo("The answer is ".$myMatchingConfigurableProductId); { $myTargetSimpleProductId = $someIdThatYouKnow; $quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item){ if ($option = $item->getOptionByCode('simple_product')) { $productIdArray[] = $option->getProduct()->getId(); //for the record if ($option->getProduct()->getId()==$myTargetSimpleProductId ){ $myMatchingConfigurableProductId = $item->getProductId(); //capture the ID of the configurable } } } //$productIdArray holds a list of all the IDs of simple products that are in the basket due to configurables. echo("The answer is ".$myMatchingConfigurableProductId); getOptionByCode ( 'simple_product')) { $myTargetSimpleProductId = $someIdThatYouKnow; $quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item){ if ($option = $item->getOptionByCode('simple_product')) { $productIdArray[] = $option->getProduct()->getId(); //for the record if ($option->getProduct()->getId()==$myTargetSimpleProductId ){ $myMatchingConfigurableProductId = $item->getProductId(); //capture the ID of the configurable } } } //$productIdArray holds a list of all the IDs of simple products that are in the basket due to configurables. echo("The answer is ".$myMatchingConfigurableProductId); getProduct () -> getId (); $myTargetSimpleProductId = $someIdThatYouKnow; $quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item){ if ($option = $item->getOptionByCode('simple_product')) { $productIdArray[] = $option->getProduct()->getId(); //for the record if ($option->getProduct()->getId()==$myTargetSimpleProductId ){ $myMatchingConfigurableProductId = $item->getProductId(); //capture the ID of the configurable } } } //$productIdArray holds a list of all the IDs of simple products that are in the basket due to configurables. echo("The answer is ".$myMatchingConfigurableProductId); -> getId () == $ myTargetSimpleProductId) { $myTargetSimpleProductId = $someIdThatYouKnow; $quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item){ if ($option = $item->getOptionByCode('simple_product')) { $productIdArray[] = $option->getProduct()->getId(); //for the record if ($option->getProduct()->getId()==$myTargetSimpleProductId ){ $myMatchingConfigurableProductId = $item->getProductId(); //capture the ID of the configurable } } } //$productIdArray holds a list of all the IDs of simple products that are in the basket due to configurables. echo("The answer is ".$myMatchingConfigurableProductId); ); $myTargetSimpleProductId = $someIdThatYouKnow; $quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item){ if ($option = $item->getOptionByCode('simple_product')) { $productIdArray[] = $option->getProduct()->getId(); //for the record if ($option->getProduct()->getId()==$myTargetSimpleProductId ){ $myMatchingConfigurableProductId = $item->getProductId(); //capture the ID of the configurable } } } //$productIdArray holds a list of all the IDs of simple products that are in the basket due to configurables. echo("The answer is ".$myMatchingConfigurableProductId); the IDs of simple products that are in the basket due to configurables. $myTargetSimpleProductId = $someIdThatYouKnow; $quote = Mage::getSingleton('checkout/session')->getQuote(); $cartItems = $quote->getAllVisibleItems(); foreach ($cartItems as $item){ if ($option = $item->getOptionByCode('simple_product')) { $productIdArray[] = $option->getProduct()->getId(); //for the record if ($option->getProduct()->getId()==$myTargetSimpleProductId ){ $myMatchingConfigurableProductId = $item->getProductId(); //capture the ID of the configurable } } } //$productIdArray holds a list of all the IDs of simple products that are in the basket due to configurables. echo("The answer is ".$myMatchingConfigurableProductId); 

Code adapted from this Q & A , and that the Q & A and did not tested, so please let me know if this bomb badly, and you can not understand all the fixes.

**** EDIT to explain the code a bit more, following the comment below ***

In general, it helps to understand that when someone adds a configurable product in the shopping cart, Magento largely retains custom product ID, not the identity of the product base a simple product. But Magento, being Magento, configured product in the basket is complicated object, part of which is a reference to simple plain product.

So:

 $item->getProductId(); //Really means [pseudo code] $item->getConfiguredProductId() $item->getOptionByCode('simple-product') //Accesses the underlying simple product object, hence $item->getOptionByCode('simple-product')->getProduct()->getId() //gives accesse to the ID of the underlying simple product - ie the thing you want to test. item-> getConfiguredProductId () $item->getProductId(); //Really means [pseudo code] $item->getConfiguredProductId() $item->getOptionByCode('simple-product') //Accesses the underlying simple product object, hence $item->getOptionByCode('simple-product')->getProduct()->getId() //gives accesse to the ID of the underlying simple product - ie the thing you want to test. product') // Accesses the underlying simple product object, hence $item->getProductId(); //Really means [pseudo code] $item->getConfiguredProductId() $item->getOptionByCode('simple-product') //Accesses the underlying simple product object, hence $item->getOptionByCode('simple-product')->getProduct()->getId() //gives accesse to the ID of the underlying simple product - ie the thing you want to test. 

Now, if you are on a success page, the challenge is how to get access to the items of the order. To do this, there are spraying responses to Stack Overflow, and here's a sample:

 $_order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); foreach ($_order->getAllItems() as $item) { sales / order') -> loadByIncrementId ($ this-> getOrderId ()); $_order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); foreach ($_order->getAllItems() as $item) { 

because of this A & Q . Or

 $_customerId = Mage::getSingleton('customer/session')->getCustomerId(); $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getSingleton('sales/order'); $order->load($lastOrderId); foreach ($order->getItemsCollection() as $item) { customer / session') -> getCustomerId (); $_customerId = Mage::getSingleton('customer/session')->getCustomerId(); $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getSingleton('sales/order'); $order->load($lastOrderId); foreach ($order->getItemsCollection() as $item) { ; $_customerId = Mage::getSingleton('customer/session')->getCustomerId(); $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getSingleton('sales/order'); $order->load($lastOrderId); foreach ($order->getItemsCollection() as $item) { 

or observer function:

 $order = $observer->getOrder(); /* @var $item Mage_Sales_Model_Order_Item */ foreach ($order->getItemsCollection() as $item) { ); $order = $observer->getOrder(); /* @var $item Mage_Sales_Model_Order_Item */ foreach ($order->getItemsCollection() as $item) { 

both because of the A & Q .

But I think you could greatly benefit from this lesson from Magento savvy Yireo:

 $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); $cartItems = $order->getAllItems(); foreach($cartItems as $item) { checkout / session') -> getLastRealOrderId (); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); $cartItems = $order->getAllItems(); foreach($cartItems as $item) { ); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); $cartItems = $order->getAllItems(); foreach($cartItems as $item) { 

because Jisse Reitsma of Yireo.com

So you have to be tuned. There are a few bits and pieces that can be combined in your final code, but I think that you either put your code template/checkout/success.phtml , or observer at checkout_type_onepage_save_order_after , and fragments of the above will help you.

**** NEXT IMAGE ***

If you have a $product , ie product_type = 'configurable' , then to obtain its SKU you have to call $product->getData('sku'); ); If you call only $product->getSku(); Which will always return a simple SKU due

 //file: app/code/core/Mage/Core/Catalog/Model/Product.php //class: Mage_Catalog_Model_Product public function getSku() { return $this->getTypeInstance(true)->getSku($this); } -> getSku ($ this); //file: app/code/core/Mage/Core/Catalog/Model/Product.php //class: Mage_Catalog_Model_Product public function getSku() { return $this->getTypeInstance(true)->getSku($this); } 

and if you run the code, you will find

 //file: app/code/core/Mage/Core/Catalog/Model/Product/Type/Configurable.php //class: Mage_Catalog_Model_Product_Type_Configurable public function getSku($product = null) { $sku = $this->getProduct($product)->getData('sku'); if ($this->getProduct($product)->getCustomOption('option_ids')) { $sku = $this->getOptionSku($product,$sku); } return $sku; } / Mage / Core / Catalog / Model / Product / Type / Configurable.php //file: app/code/core/Mage/Core/Catalog/Model/Product/Type/Configurable.php //class: Mage_Catalog_Model_Product_Type_Configurable public function getSku($product = null) { $sku = $this->getProduct($product)->getData('sku'); if ($this->getProduct($product)->getCustomOption('option_ids')) { $sku = $this->getOptionSku($product,$sku); } return $sku; } product) -> getCustomOption ( 'option_ids')) { //file: app/code/core/Mage/Core/Catalog/Model/Product/Type/Configurable.php //class: Mage_Catalog_Model_Product_Type_Configurable public function getSku($product = null) { $sku = $this->getProduct($product)->getData('sku'); if ($this->getProduct($product)->getCustomOption('option_ids')) { $sku = $this->getOptionSku($product,$sku); } return $sku; } $ product, $ sku); //file: app/code/core/Mage/Core/Catalog/Model/Product/Type/Configurable.php //class: Mage_Catalog_Model_Product_Type_Configurable public function getSku($product = null) { $sku = $this->getProduct($product)->getData('sku'); if ($this->getProduct($product)->getCustomOption('option_ids')) { $sku = $this->getOptionSku($product,$sku); } return $sku; } 

I would add that I have a lot of test code. When I install an observer at the event checkout_type_onepage_save_order_after , the

 $cartItems = $observer->getEvent()->getOrder()->getAllVisibileItems(); foreach ($cartItems as $item){ if ($item->getProductType() == 'configurable') { $skuConfigurable = $item->getProduct()->getData('sku'); $skuMatchingSimple = $item->getProduct()->getSku(); Mage::log("skuConfigurable ".$skuConfigurable." has skuMatchingSimple ".$skuMatchingSimple, null, 'mylogfile.log'); }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } } ) -> getOrder () -> getAllVisibileItems (); $cartItems = $observer->getEvent()->getOrder()->getAllVisibileItems(); foreach ($cartItems as $item){ if ($item->getProductType() == 'configurable') { $skuConfigurable = $item->getProduct()->getData('sku'); $skuMatchingSimple = $item->getProduct()->getSku(); Mage::log("skuConfigurable ".$skuConfigurable." has skuMatchingSimple ".$skuMatchingSimple, null, 'mylogfile.log'); }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } } { $cartItems = $observer->getEvent()->getOrder()->getAllVisibileItems(); foreach ($cartItems as $item){ if ($item->getProductType() == 'configurable') { $skuConfigurable = $item->getProduct()->getData('sku'); $skuMatchingSimple = $item->getProduct()->getSku(); Mage::log("skuConfigurable ".$skuConfigurable." has skuMatchingSimple ".$skuMatchingSimple, null, 'mylogfile.log'); }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } } == 'configurable') { $cartItems = $observer->getEvent()->getOrder()->getAllVisibileItems(); foreach ($cartItems as $item){ if ($item->getProductType() == 'configurable') { $skuConfigurable = $item->getProduct()->getData('sku'); $skuMatchingSimple = $item->getProduct()->getSku(); Mage::log("skuConfigurable ".$skuConfigurable." has skuMatchingSimple ".$skuMatchingSimple, null, 'mylogfile.log'); }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } } ) -> getData ( 'sku'); $cartItems = $observer->getEvent()->getOrder()->getAllVisibileItems(); foreach ($cartItems as $item){ if ($item->getProductType() == 'configurable') { $skuConfigurable = $item->getProduct()->getData('sku'); $skuMatchingSimple = $item->getProduct()->getSku(); Mage::log("skuConfigurable ".$skuConfigurable." has skuMatchingSimple ".$skuMatchingSimple, null, 'mylogfile.log'); }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } } "(not configurable product)", null, 'mylogfile.log'.); $cartItems = $observer->getEvent()->getOrder()->getAllVisibileItems(); foreach ($cartItems as $item){ if ($item->getProductType() == 'configurable') { $skuConfigurable = $item->getProduct()->getData('sku'); $skuMatchingSimple = $item->getProduct()->getSku(); Mage::log("skuConfigurable ".$skuConfigurable." has skuMatchingSimple ".$skuMatchingSimple, null, 'mylogfile.log'); }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } } 

Works with treatment, but when I get access to the elements of the order of success.phtml , then both getSku() and getData('sku') return a custom SKU. It makes me think that I will not boot sales/order correctly or do not understand how to install "adjustable parameter" of custom $item . But I can not understand why there is a difference between `$ item 'in the observer compared to success.phtml.

You probably already know this, but I thought I would add that if you catch an event, you can get access to both the object of sale / quotes and objects sale / order, but by the time you get success.phtml sales / quote facility was the reset, and you can only access the sales / order (which I think is right for you if all you need is a configurable sku).

Here is the code that I run into success.phtml file, for me, it returns configuration code

 <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); SKUs from the order <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); checkout / session'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); customer / session'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); orderId.); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); (); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); ); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); PHTML - PHTML - PHTML - PHTML - PHTML - PHTML - PHTML--', null, 'mylogfile.log'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); order):', null, 'mylogfile.log'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); { <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); item-> getProductId (), null, 'mylogfile.log'.); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); $ item-> getProductType (), null, 'mylogfile.log'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); $ item-> getRealProductType (), null, 'mylogfile.log'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); (not simple_product option)", null, 'mylogfile.log'.); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); == 'configurable') { <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); ) -> getData ( 'sku'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); " $ dummy, null, 'mylogfile.log'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); simpleSku' => $ item-> getProduct () -> getSku (), 'configurableSku' => $ item-> getProduct () -> getData ( 'sku')); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); "(not configurable product)", null, 'mylogfile.log'.); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); .print_r ($ item-> getOptions (), true), null, 'mylogfile.log'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); -> getId ()" $ item-> getProduct () -> getId (), null, 'mylogfile.log'.); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); .print_r ($ myAnswers, true), null, 'mylogfile.log'); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); , null, 'mylogfile.log' <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); ) {// NEVER RUNS - how get the configurable product options? <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); item-> getOptions (), true)); <?php //TEST CODE to retirvie SKUs from the order $_checkoutSession = Mage::getSingleton('checkout/session'); $_customerSession = Mage::getSingleton('customer/session'); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo("<br>Order Id".$orderId); $myTargetSimpleProductId = 42;//$someIdThatYouKnow; //$cartItems = $order->getAllVisibleItems(); //returns the configurable items only $cartItems = $order->getAllItems(); Mage::log(':PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--PHTML--', null, 'mylogfile.log'); Mage::log(':', null, 'mylogfile.log'); Mage::log('cartItems (from order):', null, 'mylogfile.log'); foreach ($cartItems as $item){ Mage::log("product_id".$item->getProductId(), null, 'mylogfile.log'); Mage::log("product_type".$item->getProductType(), null, 'mylogfile.log'); Mage::log("product_real_type".$item->getRealProductType(), null, 'mylogfile.log'); if ($option = $item->getOptionByCode('simple_product')) { //NEVER RETURNS TRUE, why? Mage::log("item_opByCode_getProd_getId".$item->getOptionByCode('simple_product')->getProduct()->getId(), null, 'mylogfile.log'); }else{ Mage::log("item_opByCode_getProd_getId"." (not simple_product option)", null, 'mylogfile.log'); } if ($item->getProductType() == 'configurable') { $dummy = $item->getProduct()->getData('sku'); Mage::log("Configurable SKU ".$dummy, null, 'mylogfile.log'); $myAnswers[]=array('simpleSku'=>$item->getProduct()->getSku(),'configurableSku'=>$item->getProduct()->getData('sku')); //in success.phtml these two are always the same (the configurable SKU) }else{ Mage::log("Configurable SKU"." (not configurable product)", null, 'mylogfile.log'); } Mage::log("item options".print_r($item->getOptions(),true), null, 'mylogfile.log'); Mage::log("getProduct()->getId()".$item->getProduct()->getId(), null, 'mylogfile.log'); Mage::log("getProduct()->getSku".$item->getProduct()->getSku(), null, 'mylogfile.log'); Mage::log("getProduct()->getName()".$item->getProduct()->getName(), null, 'mylogfile.log'); Mage::log("SKUs : ".print_r($myAnswers,true), null, 'mylogfile.log'); Mage::log("<br>********************************", null, 'mylogfile.log'); if($item->getOptions()){ //NEVER RUNS - how get the configurable product options? echo("OPTIONS".print_r($item->getOptions(),true)); } } echo("SKU array".print_r($myAnswers,true)); 

Hope something here works for you. Once in the past I wrote a theme that puts a simple product into the basket, even if he has emerged as a configurable option, so you may want to check that your subject does not do this (developing this code in the default theme, yet it does not work)

+3
source

I just need the SKU for AJAX trolley function. This worked for me:

 $cart = Mage::helper('checkout/cart')->getCart(); $items = $cart->getItems(); foreach ($items as $item) { if ($item->getProductType() == 'configurable') { $sku = $item->getProduct()->getData('sku'); } else { $sku = $item->getSku(); // simple product } } checkout / cart') -> getCart (); $cart = Mage::helper('checkout/cart')->getCart(); $items = $cart->getItems(); foreach ($items as $item) { if ($item->getProductType() == 'configurable') { $sku = $item->getProduct()->getData('sku'); } else { $sku = $item->getSku(); // simple product } } { $cart = Mage::helper('checkout/cart')->getCart(); $items = $cart->getItems(); foreach ($items as $item) { if ($item->getProductType() == 'configurable') { $sku = $item->getProduct()->getData('sku'); } else { $sku = $item->getSku(); // simple product } } == 'configurable') { $cart = Mage::helper('checkout/cart')->getCart(); $items = $cart->getItems(); foreach ($items as $item) { if ($item->getProductType() == 'configurable') { $sku = $item->getProduct()->getData('sku'); } else { $sku = $item->getSku(); // simple product } } ); $cart = Mage::helper('checkout/cart')->getCart(); $items = $cart->getItems(); foreach ($items as $item) { if ($item->getProductType() == 'configurable') { $sku = $item->getProduct()->getData('sku'); } else { $sku = $item->getSku(); // simple product } } 

The answer is pulled mainly from Malachi thesis ...

+2
source

Have any direct function to extract the product parent sku

  <?php $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($childproid); /* $parentIds is array of ids */ foreach( $parentIds as $eachProID) $child=Mage::getModel('catalog/product')->load($eachProID); } ?> * /  <?php $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($childproid); /* $parentIds is array of ids */ foreach( $parentIds as $eachProID) $child=Mage::getModel('catalog/product')->load($eachProID); } ?> catalog / product') -> load ($ eachProID);  <?php $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($childproid); /* $parentIds is array of ids */ foreach( $parentIds as $eachProID) $child=Mage::getModel('catalog/product')->load($eachProID); } ?> 
+1
source

All Articles