/**
@param $productsIDs array of product IDs to compare
@param $compareBy array of attribute IDs to include in the result compare list
*/
function __construct($productsIDs, $compareBy)
{
$prodAttributes = array();
foreach ($productsIDs as $prodId) {
$product = new Product($prodId);
$prodAttributes[$product->id()] = $product->attributes();
$this->items[$product->id()] = array();
}
foreach ($compareBy as $attrId) {
foreach ($prodAttributes as $prodId => $attrs) {
$attr = new Attribute($attrId);
if ($this->isSetInAtLeastOne($prodAttributes, $attr->id())) {
$this->items[$prodId][$attr->id()] = $attrs->get($attr->id());
$this->fullList[$attr->id()] = $attr;
if (!$this->isEqualForAll($prodAttributes, $attr->id())) {
$this->listOfDifferences[$attr->id()] = $attr;
}
}
}
}
}