Name / Dateiname der Rechnung bzw des pdf Beleges anpassen

Hi 

über welches Event oder hook würde ich am besten den Namen bzw Datei Namen des Rechnungsbeleges anpassen?

 

danke 

Hi,

so wie ich das sehe, kommst du da so direkt nicht dran, du könntest *nach* der Generierung aber ggf. den hash in „s_order_documents“ anpassen und die Datei nach deinen Vorgaben umbenennen. Das dann bspw. als Hook / PostDispatch nach der \Shopware_Controllers_Backend_Order::createDocumentAction oder der \Shopware_Controllers_Backend_Order::batchProcessAction. 

Daniel

Yes, @Daniel‍ way should be helpful. In my case I had to HOOK Shopware_Components_Document_render() for handling filename change. Below is sample code snippet

/**
     * Triggers the plugin installation
     *   
     * @return null
     */
    public function install()
    {
      $this->subscribeEvent(
            'Shopware_Components_Document::render::before',
            'beforeDocumentRender'
        );
    }

/**
     * Hook listener function called via the Shopware_Components_Document event.     
     *
     * @param Enlight_Event_EventArgs $arguments
     */
    public function beforeDocumentRender(Enlight_Event_Hooks $arguments)
    {
        $aRenderer = $arguments->get("_renderer");
        
        // if renderer is empty then?
        // call is made from BE
        if (empty($aRenderer) && $_REQUEST['temp']) {
            $aRenderer = array(
                'render' => 'pdf',
                'preview' => $_REQUEST['preview'],
                'orderid' => $_REQUEST['orderId'],
            );
        }
        try {
            require_once(Shopware()->AppPath("Plugins") . "/Local/Backend/PdfaPrinter/Components/PdfaDocument.php");
        
            $pdfaDoc = Enlight_Class::Instance('PdfaDocument');
            $pdfaDoc->pdfaRender($aRenderer);
        } catch(Exception $e) {
            echo $e->__toString();die;
        }        
    }

Do correct me if I am wrong anywhere :slight_smile:

Danke euch. Ich probiere das mal damit :slight_smile:

Where did you actually Change the file Name?

@abdul.ahad2k14 schrieb:

Yes, @Daniel‍ way should be helpful. In my case I had to HOOK Shopware_Components_Document_render() for handling filename change. Below is sample code snippet

/**

  • Triggers the plugin installation
  • @return null
    */
    public function install()
    {
    $this->subscribeEvent(
    ‚Shopware_Components_Document::render::before‘,
    ‚beforeDocumentRender‘
    );
    }

/**

  • Hook listener function called via the Shopware_Components_Document event.
  • @param Enlight_Event_EventArgs $arguments
    */
    public function beforeDocumentRender(Enlight_Event_Hooks $arguments)
    {
    $aRenderer = $arguments->get(„_renderer“);

// if renderer is empty then?
// call is made from BE
if (empty($aRenderer) && $_REQUEST[‚temp‘]) {
$aRenderer = array(
‚render‘ => ‚pdf‘,
‚preview‘ => $_REQUEST[‚preview‘],
‚orderid‘ => $_REQUEST[‚orderId‘],
);
}
try {
require_once(Shopware()->AppPath(„Plugins“) . „/Local/Backend/PdfaPrinter/Components/PdfaDocument.php“);

$pdfaDoc = Enlight_Class::Instance(‚PdfaDocument‘);
$pdfaDoc->pdfaRender($aRenderer);
} catch(Exception $e) {
echo $e->__toString();die;
}
}

Do correct me if I am wrong anywhere :)