Header Ad

Showing posts with label Brands in Magento. Show all posts
Showing posts with label Brands in Magento. Show all posts

Tuesday, April 3, 2012

Events & Observers in Magento


The following is the command used to get the list of events in magento installed version.

grep -rin -B2 -A2 "Mage::dispatchEvent" app/* > events.txt

In Magentov1.4, nearly 300 events compared to 223 in v1.3 and 140 in v1.2.

The following is the sample example for writing "events".

<events>
  <EVENT_TO_HOOK>
    <observers>
      <module>
        <type>singleton</type>
        <class>company_module_model_observer</class>
        <method>methodToCall</method>
      </module>
    </observers>
  </EVENT_TO_HOOK>  
</events>

Writing multiple observers for same event

We can write multiple observers for same event, like as follows.

    <observers>
      <shipmentsave>
        <type>singleton</type>
        <class>bshipment/observer</class>
        <method>salesOrderShipmentSaveBefore</method>
      </shipmentsave>
    </observers>

   <observers>
      <bshipmentsave>
        <type>singleton</type>
        <class>bshipment/observer</class>
        <method>salesOrderShipmentSaveBefore</method>
      </bshipmentsave>
    </observers>

If we observe in the above XML tags, we have "<shipmentsave>" and "<bshipmentsave>". Where we can write these tags in different modules respectively.

Monday, April 26, 2010

how to change pdf font & styles in magento

All the Pdf which are related to the order is available in the following location.

/app/code/local/Mage/Sales/Model/Order/Pdf/

We can edit the invoice pdf font & styles in magento. Please follow the below inorder to successed the changes.

Page format: The default invoice PDF is set up in the A4 format. To set it for letter in /app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php

change

$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);

to

$page = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);

Wednesday, April 21, 2010

Ability to retrieve products under a brand or manufacturer in MAGENTO

$brandId = "1"; //manufacturer id or brand id
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('manufacturer', array('in' => array($brandId)));
$products->addAttributeToFilter('status', '1');
$products->addAttributeToSelect('*');
$products->load();

echo "
";
foreach($products as $product)
echo $product->getId()."
";

Monday, April 5, 2010

Changing the Magento Favicon

If you’re using a default theme, the new favicon.ico needs to be uploaded into the /skin/frontend/default/default/favicon.ico directory.

For custom themes, the favicon should go into the /skin/frontend/default/CUSTOM_THEME/favicon.ico directory instead. That was simple and we have successfully updated our favicon! To view it we need to clear the browser cookies and cache and hit refresh.

Thursday, April 1, 2010

Magento Vendor Notification

Hi,

This is one of the link which i came across in MAGENTO for vendor notification. This mighe be useful for somebody.

http://www.magentocommerce.com/extension/1193/vendor-notifications

Ability to get all the manufacurers or brands in Magento

We can use the following code to get the list of manufacturers in MAGENTO.

$product = Mage::getModel('catalog/product');

//Retriving the attribute values for the manufacturer id
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer') // This can be changed to any attribute code
->load(false);

$attribute = $attributes->getFirstItem()->setEntity($product->getResource());

//This is an array of manufacturers
$manufacturers = $attribute->getSource()->getAllOptions(false);