Help Required for Addon Development

Hi everyone,



i am new to cs-cart. i am trying to developing a addon for Filling section but its not working. my code detail is given below.



addons/MYADDON2011/schemas/block_manager/specific_settings.post.php


```php


if ( !defined('AREA') ) { die('Access denied'); }

$schema['fillings']['MYADDON2011'] = array (
'limit' => array (
'type' => 'input',
'default_value' => 9,
)
);

?>

```



addons/MYADDON2011/schemas/block_manager/structure.post.php


```php


if ( !defined('AREA') ) { die('Access denied'); }



$schema['products']['fillings']['MYADDON2011'] = array (
'params' => array (

'request' => array(
'MYADDON2011_for_product_id' => '%PRODUCT_ID%',
'item_ids' => array ()
),

),
'locations' => array(
'products'
),

'update_handlers' => array ('MYADDON2011'),
);

?>

```





addons/MYADDON2011/init.php


```php



if ( !defined('AREA') ) { die('Access denied'); }

fn_register_hooks(
'get_products'
);

?>

```


addons/MYADDON2011/func.php

```php



if ( !defined('AREA') ) { die('Access denied'); }



function fn_MYADDON2011_get_products(&$params, &$condition)
{
if (!empty($params['MYADDON2011_for_product_id'])) {
$CID_ = db_get_fields("SELECT category_id FROM ?:products_categories WHERE product_id = ?i AND link_type = 'M'", $params['MYADDON2011_for_product_id']);
$All_C_P = db_get_fields("SELECT product_id FROM ?:products_categories WHERE category_id = ?i AND link_type = 'M' AND product_id != ?i ",$CID, $params['MYADDON2011_for_product_id'] );

//
//
//$All_C_P => My custom functions on $All_C_P to get products according to my need
//
//
$params['item_ids'] => $All_C_P
}

return true;
}

?>
```


but when i add this block to my product page, but it doesn't show any product

please correct my where i am wrong.

i shall be thankful.

Albela

Not quite sure what you're trying to do here.

Generally when using the 'get_products' hook, you want to adjust the join and conditions to allow the final DB query to process as you want. Setting params won't do much since they are already processed by the parent function. They are there to refer to so you can set them and trigger off of their settings as passed in by the block manager.



If you are wanting to set it so the query restricts to your list of product_ids, then you should use that in the condition by setting $condition .= db_quote(" AND ?:products.product_id in (?p) ", $CID_);



Note also your function should be defined as:


function fn_MYADDON2011_get_products(&$params, &$join, &$condition)


to return the condition (3rd parameter of the fn_set_hook() in fn_get_products()).