Magento get configurable product from simple product

If you need to get the configurable product from a simple one, you can do this

$simpleProductId = 666;
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
$configurableProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
echo $configurableProduct->getId(); 

Make a PDF into magento using zend_pdf

Here my code to generate a PDF file into Magento using the zend_pdf embeded library.

//in my controller
public function prindPdfAction()
        $pdf = new Zend_Pdf();
        $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
        $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
        $page->setFont($font, 12);

        //add a logo
        $image = Mage::getBaseDir('media').'/logo_pdf.jpg';
        if (is_file($image)) {
            $image = Zend_Pdf_Image::imageWithPath($image);
            $x = 20;
            $y = 700;
            $page->drawImage($image, $x, $y, $x + 118, $y + 112);

        //add text
        $page->setFont($font, 16);
        $titre = "Ecole ";
        $page->drawText($titre, 155, $page->getHeight()-85, "UTF-8");

        //add pages to main document
        $pdf->pages[] = $page;

        //generate pdf
        $content =  $pdf->render();

        $fileName = 'details.pdf';
        //send it to the browser to download
        $this->_prepareDownloadResponse($fileName, $content);

Magento link in backend redirect to dashboard

You are working on Magento backoffice and make a link to a new page but when you click on your anchor, you are redirected to the dashboard ?

Here how to make a proper link :

   echo "<a href='".Mage::helper('adminhtml')->getUrl('*/*/displaydetail', array('id' => $cour['id']))."' >".$cour['name']."</a>";

Something like


doesn’t work, even if I had the FormKey. But you can use it for ajax request

        url: "<?php echo Mage::getUrl('*/*/classroomfromplaceAjax') ?>",
        type: "POST",
        dataType: 'json',
        data: 'place_id=' + place_id + '&index=' + index + '&form_key=' + window.FORM_KEY,
        success: function (data) {
            jQuery('#classroom_' + index).html(data.html);