Imported Quoted Line Items Not Displaying Under Quotation

Sugar 13.3

I tried to import some rows of Quoted Line Items related in an existing Quote.

Everything seems to work correctly, in the Quoted Line Items detail I see the reference to the parent Quote, but when I open the Quote detail the imported rows are not visible.

How can I solve this problem?

Thanks for your support

  • Hi  ,

    I never try to import QLI from the interface, but the fact is that each QLI is linked to a quote through a bundle.

    Using the QLI importation, the QLI is created, linked with the Quote BUT the entry is not created in the table PRODUCT_BUNDLE_PRODUCT.

    I don't know if there is a way to specify the bundle during the CSV importation process.

    Fred

  • To be shown in the Quote, the QLIs must have a Product Bundle assigned.

    There is no chance to assign a Prodcut Bundle when importing QLIs (Products).

    So you have 2+ possiblities:

    - Import the QLIs by some API calls ( which may be the best solution ), see here also  Import Quotes from ERP 

    or

    - Create a logic_hook which sets the Product Bundle to the default (nameless) Product Bundle of a Quote.

    The logic:look can be very simple, just check whether the Product Bundle is already set and if not, search the default ProductBundle of the related Quote and assign it.

    Look to the following example:

    custom\Extension\modules\Products\Ext\LogicHooks\checkBundleHooks.php:

    <?php
    $hook_version = 1;
    if (!isset($hook_array)) {
        $hook_array = array();
    }
    
    if (!isset($hook_array['after_save'])) {
        $hook_array['after_save'] = array();
    }
    
    $hook_array['after_save'][] = array(
        200,
        'saved quoted line item',
        'custom/modules/Products/checkBundle.php', 
        'checkBundle',
        'setBundle'
    );

    and custom\modules\Products\checkBundle.php:

    <?php
    
    class checkBundle
    {
        public function setBundle($bean, $event, $arguments)
        {
    		//If relationship is loaded
    		if ($bean->load_relationship('product_bundles')) {
    			//Fetch related beans
    			$relatedBeans = $bean->product_bundles->getBeans();
    			if (!$relatedBeans) {
    				if ($bean->quote_id) {
    					//Load Quote
    					$quote = BeanFactory::getBean('Quotes', $bean->quote_id);
    
    					//Find any Bundle
    					$newBundle = "";
    					if ($quote->load_relationship('product_bundles')) {
    						$QUbundles = $quote->product_bundles->getBeans();
    						foreach($QUbundles as $QBid => $QB) {
    //							$GLOBALS['log']->fatal('QUO PB id:'.$QBid);
    //							$GLOBALS['log']->fatal('QUO PB name:'.$QB->name);
    							//If there is a default group take it, else take the last one
    							$newBundle = $QBid;
    							if ($QB->default_group) {
    								break; 
    							}
    						}
    						if ($newBundle) {
    							//If found set relationship
    							$bean->product_bundles->add($newBundle);					
    						}
    					}
    				}
    			}
    
    		} 
        } 
    }
    

    Just a little example with no sophisticated rules for the Product Bundle selection.

    - You could also create a custom field "bundle_name_c" in the QLI module Products and then provide the bundle name in the import file.

    Instead of searching for the default flag ($QB->default_group) you could now search for ($bean->bundle_name_c == $QB->name).

    Enjoy it if you want.

  • This is a great suggestion, thanks Harald for your support

    Gian Luca