public static function addProductOptions($data, $product)
 {
     $count = count($data['pogSort']);
     $ii = 0;
     //set counter for items
     if ($count > 0) {
         for ($i = 0; $i < count($data['pogSort']); $i++) {
             $optionGroup = StoreProductOptionGroup::add($product, $data['pogName'][$i], $data['pogSort'][$i]);
             $pogID = $optionGroup->getID();
             //add option items
             $itemsInGroup = count($data['optGroup' . $i]);
             if ($itemsInGroup > 0) {
                 for ($gi = 0; $gi < $itemsInGroup; $gi++, $ii++) {
                     StoreProductOptionItem::add($product, $pogID, $data['poiName'][$ii], $data['poiSort'][$ii]);
                 }
             }
         }
     }
 }
 public static function addProductOptions($data, $product)
 {
     StoreProductOptionGroup::removeOptionGroupsForProduct($product, $data['pogID']);
     StoreProductOptionItem::removeOptionItemsForProduct($product, $data['poiID']);
     $count = count($data['pogSort']);
     $ii = 0;
     //set counter for items
     if ($count > 0) {
         for ($i = 0; $i < count($data['pogSort']); $i++) {
             if (isset($data['pogID'][$i])) {
                 $optionGroup = StoreProductOptionGroup::getByID($data['pogID'][$i]);
                 if ($optionGroup) {
                     $optionGroup->update($product, $data['pogName'][$i], $data['pogSort'][$i]);
                 }
             }
             if (!$optionGroup) {
                 if ($data['pogName'][$i]) {
                     $optionGroup = StoreProductOptionGroup::add($product, $data['pogName'][$i], $data['pogSort'][$i]);
                 }
             }
             if ($optionGroup) {
                 $pogID = $optionGroup->getID();
                 //add option items
                 $itemsInGroup = count($data['optGroup' . $i]);
                 if ($itemsInGroup > 0) {
                     for ($gi = 0; $gi < $itemsInGroup; $gi++, $ii++) {
                         if ($data['poiID'][$ii] > 0) {
                             $option = StoreProductOptionItem::getByID($data['poiID'][$ii]);
                             if ($option) {
                                 $option->update($product, $data['poiName'][$ii], $data['poiSort'][$ii], $data['poiHidden'][$ii]);
                             }
                         } else {
                             if ($data['poiName'][$ii]) {
                                 StoreProductOptionItem::add($product, $pogID, $data['poiName'][$ii], $data['poiSort'][$ii], $data['poiHidden'][$ii]);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #3
0
            echo $k;
            ?>
, true);"><?php 
            echo t("Remove");
            ?>
</a>
                            </div>
                            <?php 
            if ($cartItem['productAttributes']) {
                ?>
                                <div class="cart-list-item-attributes">
                                    <?php 
                foreach ($cartItem['productAttributes'] as $groupID => $valID) {
                    $groupID = str_replace("pog", "", $groupID);
                    $optiongroup = StoreProductOptionGroup::getByID($groupID);
                    $optionvalue = StoreProductOptionItem::getByID($valID);
                    ?>
                                        <div class="cart-list-item-attribute">
                                            <span class="cart-list-item-attribute-label"><?php 
                    echo $optiongroup ? $optiongroup->getName() : '';
                    ?>
:</span>
                                            <span class="cart-list-item-attribute-value"><?php 
                    echo $optionvalue ? $optionvalue->getName() : '';
                    ?>
</span>
                                        </div>
                                    <?php 
                }
                ?>
                                </div>
Exemple #4
0
 public function remove()
 {
     StoreProductImage::removeImagesForProduct($this);
     StoreProductOptionGroup::removeOptionGroupsForProduct($this);
     StoreProductOptionItem::removeOptionItemsForProduct($this);
     StoreProductFile::removeFilesForProduct($this);
     StoreProductGroup::removeGroupsForProduct($this);
     StoreProductLocation::removeLocationsForProduct($this);
     StoreProductUserGroup::removeUserGroupsForProduct($this);
     StoreProductVariation::removeVariationsForProduct($this);
     $em = Database::get()->getEntityManager();
     $em->remove($this);
     $em->flush();
     $page = Page::getByID($this->cID);
     if (is_object($page)) {
         $page->delete();
     }
 }
 public static function addVariations(array $data, StoreProduct $product)
 {
     $optItems = $product->getProductOptionItems();
     $optionArrays = array();
     foreach ($optItems as $optItem) {
         $optionArrays[$optItem->getProductOptionGroupID()][] = $optItem->getID();
     }
     $comboOptions = self::combinations(array_values($optionArrays));
     $variationIDs = array();
     if (!empty($comboOptions)) {
         foreach ($comboOptions as $key => $optioncombo) {
             if (!is_array($optioncombo)) {
                 $optioncomboarray = array();
                 $optioncomboarray[] = $optioncombo;
                 $optioncombo = $optioncomboarray;
             }
             $variation = self::getByOptionItemIDs($optioncombo);
             if (!$variation) {
                 $variation = self::add($product->getProductID(), array('pvSKU' => '', 'pvPrice' => '', 'pvSalePrice' => '', 'pvQty' => '', 'pvQtyUnlim' => '', 'pvfID' => '', 'pvWeight' => '', 'pvNumberItems' => '', 'pvWidth' => '', 'pvHeight' => '', 'pvLength' => ''));
                 foreach ($optioncombo as $optionvalue) {
                     $option = StoreProductOptionItem::getByID($optionvalue);
                     if ($option) {
                         $variationoption = new StoreProductVariationOptionItem();
                         $variationoption->setOption($option);
                         $variationoption->setVariation($variation);
                         $variationoption->save();
                     }
                 }
             } else {
                 $key = $variation->getID();
                 $variation->setVariationSKU($data['pvSKU'][$key]);
                 $variation->setVariationPrice($data['pvPrice'][$key]);
                 $variation->setVariationSalePrice($data['pvSalePrice'][$key]);
                 $variation->setVariationQty($data['pvQty'][$key]);
                 $variation->setVariationQtyUnlim($data['pvQtyUnlim'][$key]);
                 $variation->setVariationFID($data['pvfID'][$key]);
                 $variation->setVariationWidth($data['pvWeight'][$key]);
                 $variation->setVariationNumberItems($data['pvNumberItems'][$key]);
                 $variation->setVariationWeight($data['pvWidth'][$key]);
                 $variation->setVariationHeight($data['pvHeight'][$key]);
                 $variation->setVariationLength($data['pvLength'][$key]);
                 $variation->save();
             }
             $variationIDs[] = $variation->getID();
         }
     }
     $db = Database::connection();
     if (!empty($variationIDs)) {
         $options = implode(',', $variationIDs);
         $pvIDstoDelete = $db->getAll("SELECT pvID FROM VividStoreProductVariations WHERE pID = ? and pvID not in ({$options})", array($product->getProductID()));
     } else {
         $pvIDstoDelete = $db->getAll("SELECT pvID FROM VividStoreProductVariations WHERE pID = ?", array($product->getProductID()));
     }
     if (!empty($pvIDstoDelete)) {
         foreach ($pvIDstoDelete as $pvID) {
             $variation = self::getByID($pvID);
             if ($variation) {
                 $variation->delete();
             }
         }
     }
 }