Question

Basically in my magento store (i am using magento 1.9.2.4) I have configurable product called "Design Dino Tee Shirt" with SKU of DESIGNDINO and the associated products are lets say "Blue Color - S" with SKU of DESIGNDINOBLUES and "Blue Color - M" and DESIGNDINOBLUEM..

Now when someone orders this product and chose Blue Color - S.. everything is fine.. But by default.. the PackingSlips pdf when I print it.. the SKU shown in that PDF is that of the child product ie: DESIGNDINOBLUES.. Now my question is, How can I change that SKU to show the parent product ie: DESIGNDINO?

I know I can edit the template at this location:

/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php

And then.. under line 58:

        // draw SKU
        $lines[0][] = array(
            'text'  => Mage::helper('core/string')->str_split($this->getSku($item), 25),
            'feed'  => 565,
            'align' => 'right'
        );

I believe I need to change something along $this->getSku($item) but im not sure how and what is the correct way to do it..

Also my 2nd question is, I run multiple stores on this 1 single magento installation.. So the changes I make here I do not want it to affect other stores.. meaning the change to parent SKU for packingslips pdf should only be for this specific store and other stores should still use the default SKU of child products.. so How can I do this so that only this store is affected and not other stores in this Magento installation?

Thanks for the help! Appreciate any discussion/answers.. :)

Était-ce utile?

La solution

You have to override Default.php file from app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php

app/code/local/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php

Add below code at line no : 57 (replace $storeId == 1 with your store id in below code)

$order = $this->getOrder();
$storeId = $order->getStoreId();
if ($storeId == 1) {
    //$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($item->getId());
 /* Using Item Sku */
$child_id = Mage::getModel('catalog/product')->getIdBySku($this->getSku($item));
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($child_id);
    if ($parentIds) {
    foreach($parentIds as $configItem)
    {
            $_product = Mage::getModel('catalog/product')->load($configItem);
            if($_product->getName() == $item->getName()){ break; }
    }
        //$_product = Mage::getModel('catalog/product')->load($parentIds[0]);
        $itemSku = $_product->getSku();
    } else {
        $itemSku = $this->getSku($item);
    }
} else {
    $itemSku = $this->getSku($item);
}

Replace below code in line no : 60

'text'  => Mage::helper('core/string')->str_split($itemSku, 25),

Instead of

'text'  => Mage::helper('core/string')->str_split($this->getSku($item), 25),
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top