is there a function to know if a product is_active() ?
It would help if you indicated whether you wanted the PHP or Template method.
PHP:
$p = get_product_data(product_id);
if( $p['status'] == 'A' )
product is active
And smarty:
{if $product.status == 'A' }
product is active
{/if}
fn_get_product_data ?
oups you where faster then me lol
bascially php code, as its for the small bug i saw, a block tied to items will still show and have the items array filled even if the items are disabled/hidden
so
block buy together, with items 1 and 2… both disabled
item_ids => “1012,1597”
assigned => “Y”
object_id => “product_id”
group_id => “43”
so i can’t test on that… i guess ill loop the active status of the id’s
Yeah, fn_get_product_data()… I get too used to just using the hook names versus the names of the functions…
This doesnt show the status… .any idea ? whats the params i need to send… actually there is no status in product_data var in the fn_
{foreach from=$blocks item="ablock" key="block_id"}
{if $ablock.block_id=="32"}
{assign var="arr_productids" value=","|explode:$ablock.item_ids}
{foreach from=$arr_productids item="item"}
{php}
$myVars = $this->get_template_vars();
$item=$myVars['item'];
print $item; // prints 723 and 1653
$p = fn_get_product_data($item);
print "STATUS";print $p['status'];
if( $p['status'] == 'A' ) {
print "asdasdasd";
}
{/php}
{/foreach}
{/if}
{/foreach}
I would never use the {php} tags in a template…
I would add a {debug} and see where the array of products is being passed, then in your foreach() I would use $item.status.
If there is no product array, then I would use a 'post' controller to fetch the data for the products and then set my own variable for use in the template.
[quote name='tbirnseth' timestamp='1310418757' post='116929']
I would never use the {php} tags in a template…
I would add a {debug} and see where the array of products is being passed, then in your foreach() I would use $item.status.
If there is no product array, then I would use a 'post' controller to fetch the data for the products and then set my own variable for use in the template.
[/quote]
why not ? is a controller lighter then a php tag ?
my finished little hack… its a hack ill write a controller eventually… this is a patch becaus there is no status of the items when they not the main item… $p = fn_get_product_data2($item) is a small function to only RETRIEVE status as the main one didnt
```php
function fn_get_product_data2($product_id) {
//$product_data2=“A”;
$product_data2 = db_get_row(“SELECT status FROM ?:products WHERE ?:products.product_id = ?i “, $product_id);
return (!empty($product_data2)? $product_data2 : false);
}
AND
{foreach from=$blocks item=“ablock” key=“block_id”}
{if $ablock.block_id==“32”}
{assign var=“arr_productids” value=”,”|explode:$ablock.item_ids}
{foreach from=$arr_productids item=“item”}
{php}
$myVars = $this->get_template_vars();
$item=$myVars['item'];
$p = fn_get_product_data2($item);
if( $p['status'] == 'A' ) {
$flag=1;
$this->assign(“activeflag”,$flag);
}
{/php}
{/foreach}
{/if}
{/foreach}
{if $activeflag}
{/if} ```
It's a design and architectural issue. You're in the presentation layer, not the business layer.
Why are your returning an array containing the product status versus simply the status?
We have different styles/approaches (using PHP in presentation, hard coding block_ids, etc.). No biggy, glad you got it working to your satisfaction.
[quote name=‘tbirnseth’ timestamp=‘1310419777’ post=‘116931’]
It’s a design and architectural issue. You’re in the presentation layer, not the business layer.
Why are your returning an array containing the product status versus simply the status?
We have different styles/approaches (using PHP in presentation, hard coding block_ids, etc.). No biggy, glad you got it working to your satisfaction.
[/quote]
coz i copied the function from the same block and didnt care on returning an array or a var,
but eventually it can allow me to return more then this…
Hi Guys,
What would be the easiest way to:
(a) get the price for a product ID, into a .tpl file?
( add a buy button for a certain product ID in a .tpl file.
Thank you, just getting started.