Heckscher-Ohlin trade model with non-homothetic preferences $U^j = \prod^N_i \left(d^j_i-\bar{d}_i\right)^\oint$

where $d^j_i$ is the per capita consumption of good $i$ in any country $j$; $\bar{d}_i \geq 0$ denotes the minimum consumption of each good $i$, which are same across countries; $\displaystyle \sum_i \oint_i^j =1$. Assuming that per capita income $I^j$ is large enough to afford the minimum consumption. Derive the per capita demand for each good $i$ in country $j$.

I understand pi-product notation means it's a product function, but how do we differentiate a product function like this? I define my $I^j$ as $p_i d_i^j$; not sure if this is correct. Your help is much appreciated! Thank you in advance. :)
$I^j$ is just a known constant (i.e. we don't know anything about production, which would endogenously generate the amount of per capita income), but as you suggest the budget constraint for the consumer is that $\sum_i p_i d_i^j \leq I^j$ (here, you can assume this holds with equality).  

First, note that if $d_i^j &lt; \bar{d}_i$, then the utility function will be negative. So, if we have sufficient income to afford the minimum consumption (i.e. $\sum_i p_i \bar{d}_i \leq I^j$), to avoid this outcome the consumer will purchase at least $d_i^j \geq \bar{d}_i$ units of each good. Therefore, if we define $x_i^j \equiv d_i^j-\bar{d}_i$, we know that $x_i^j \geq 0$.

With this reformulation, we can rewrite this Stone-Geary utility function as a Cobb Douglas utility function, i.e.
$U^j = \prod_{i=1}^N (d_i^j - \bar{d}_i)^{\varphi_i}=\prod_{i=1}^N (x_i^j)^{\varphi_i}$. Then, to solve for the optimal consumption of $x_i^j$, you can just solve for optimal consumption with a Cobb Douglas utility function with a new income of $\bar{I}^j \equiv I^j - \sum_i p_i \bar{d}_i$ (that is, the remaining income left over after spending it on the minimum consumption level of each good). Once you have the optimal $x_i^j$, the optimal consumption level of the good (inclusive of the minimum) is $d_i^j = x_i^j+\bar{d}_i$.