0

I am listing three product attributes (mfg_pn, oem_pn, & physical_location) for each child product of a bundle product by using the following code after line 253 in:

app\code\local\Mage\Bundle\Model\Sales\Order\Pdf\Items\Abstract.php

           //Custom attributes
       $intProductId = $item->getProductId();
       $arrSpecProduct = Mage::getModel('catalog/product')->load($intProductId);
       $strManufacturerPartNumber = '';
       if(count($arrSpecProduct) && isset($arrSpecProduct['mfg_pn']))
       {
            $strManufacturerPartNumber = "(".$arrSpecProduct['oem_pn'].", ".$arrSpecProduct['mfg_pn'].", ".$arrSpecProduct['physical_location'].")";
       }
        if ($attributes) {
            $result =  sprintf('%d', $attributes['qty']) . ' x ' . $result.' '.$strManufacturerPartNumber;
        }
    }

The attributes get listed but I am getting the following error in system.log every time we generate a PDF invoice. We are running Magento 1.9.4.3 and PHP 7.2.22. What am I doing wrong?

2019-10-23T13:36:34+00:00 ERR (3): Warning: count(): Parameter must be an array or an object that implements Countable  in /chroot/home/user/domain.com/html/includes/src/Mage_Bundle_Model_Sales_Order_Pdf_Items_Abstract.php on line 258
1

$arrSpecProduct is not counable. Try count($arrSpecProduct->getData())

  • It worked, thank you!!! – Dan Oct 24 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.