Example #1
0
 private function pricingInformation(Product $product)
 {
     // $this->locale->translationManager()->loadFile('backend/Product');
     // $product = Product::getInstanceByID($this->request->get('id'), ActiveRecord::LOAD_DATA, ActiveRecord::LOAD_REFERENCES);
     // $pricingForm = $this->buildPricingForm($product);
     $f = new ARSelectFilter(new NotEqualsCond(new ARFieldHandle('Currency', 'isDefault'), true));
     $f->setOrder(new ARFieldHandle('Currency', 'position'));
     $otherCurrencies = array();
     foreach (ActiveRecordModel::getRecordSetArray('Currency', $f) as $row) {
         $otherCurrencies[] = $row['ID'];
     }
     $response = new ActionResponse();
     $response->set("product", $product->toFlatArray());
     $response->set("otherCurrencies", $otherCurrencies);
     $response->set("baseCurrency", $this->application->getDefaultCurrency()->getID());
     $response->set("pricingForm", $pricingForm);
     // get user groups
     $f = new ARSelectFilter();
     $f->setOrder(new ARFieldHandle('UserGroup', 'name'));
     $groups[0] = $this->translate('_all_customers');
     foreach (ActiveRecordModel::getRecordSetArray('UserGroup', $f) as $group) {
         $groups[$group['ID']] = $group['name'];
     }
     $groups[''] = '';
     $response->set('userGroups', $groups);
     // all product prices in a separate array
     $prices = array();
     foreach ($product->getRelatedRecordSetArray('ProductPrice', new ARSelectFilter()) as $price) {
         $prices[$price['currencyID']] = $price;
         $pricingForm->set('price_' . $price['currencyID'], $price['price']);
         $pricingForm->set('listPrice_' . $price['currencyID'], $price['listPrice']);
     }
     $response->set('prices', $prices);
     return $response;
 }
Example #2
0
 public static function getProductRatingsArray(Product $product)
 {
     $f = new ARSelectFilter();
     $f->setOrder(new ARFieldHandle('ProductRatingType', 'position'));
     return $product->getRelatedRecordSetArray('ProductRatingSummary', $f, array('ProductRatingType'));
 }