The product stock report does not list monthly sales, weekly sales, and stock lifetime for products with numerical SKUs.

Comments

greenskin’s picture

The array_multisort() function re-indexes numerical keys. Here's a patch that fixes the issue, allowing for support of numerical product SKUs.

greenskin’s picture

Status: Active » Needs review
mglaman’s picture

The stock module just got overhauled in the beta1 release. This kind like it'd still be an issue, but could you confirm? Thanks!

vensires’s picture

Hello, I had the same problem but the patch above didn't fix it. What did fix it though was to replace the data[$sku] = array(....); code found in commerce_reports_stock.module(line 93) with the following code:

$data[(string)$sku] = array(
  'sku' => (string)$sku,
  'stock' => (string)$stock,
  'weeklysales' => sprintf('%0.1f', $weekly_burn),
  'monthlysales' => sprintf('%0.1f', $monthly_burn),
  'lifetime' => (string)$lifetimes[(string)$sku],
);

The problem is that this $data is then processed by drupal_render() which tries to render numeric indexes as values and just fails. It seems that array_multisort() is also working fine even with strings and SORT_NUMERIC option.

mglaman’s picture

Status: Needs review » Needs work

Thanks, vensires. Render is probably expecting numeric keys to be part of elennt subchildren. That makes sense. So really when $sku is defined we need to typecast it to string. I'm not sure we need any other modifications.

mglaman’s picture

Marking this under the beta2 release plan #2425267: [META] 4.0 Beta2 Release Plan

  • mglaman committed df1e27a on 7.x-4.x
    Issue #2304519 by greenSkin: Broken stock report for products with...
mglaman’s picture

Status: Needs work » Fixed

Updated to ensure that the SKU gets casted as a string when we initialize the variable. Fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.