Пример #1
0
 public function upgrade()
 {
     $pkg = Package::getByHandle('vivid_store');
     if (version_compare($pkg->getPackageVersion(), '3.1.2', '<')) {
         Installer::upgrade($pkg);
     }
     parent::upgrade();
     $this->installStore();
 }
Пример #2
0
 public function upgrade()
 {
     $pkg = Package::getByHandle('vivid_store');
     Installer::upgrade($pkg);
     $this->installStore();
 }
Пример #3
0
 public function upgrade()
 {
     $pkg = Package::getByHandle('vivid_store');
     if (version_compare($pkg->getPackageVersion(), '2.1', '<')) {
         Installer::renameDatabaseTables($pkg);
         Installer::refreshDatabase($pkg);
         /** Version 1.1 ***********************************************/
         /**************************************************************/
         /*
          * 1. Installs new payment method: Invoice
          *
          */
         $invoicePM = PaymentMethod::getByHandle('invoice');
         if (!is_object($invoicePM)) {
             PaymentMethod::add('invoice', 'Invoice', $pkg);
         }
         /** Version 2.0 ***********************************************/
         /**************************************************************/
         /*
          * 1. Installs new PageType: store_product
          * 2. Installs a parent page to publish products under
          * 3. Install Product block
          * 4. Set pagetype defaults
          * 5. Give default for measurement units
          * 6. Install a fileset for digital downloads
          * 7. Install product attributes
          *
          */
         /*
          * 1. Installs new PageType: store_product
          */
         $this->installStoreProductPageType($pkg);
         /*
          * 2. Installs a parent page to publish products under
          */
         //first check and make sure the config isn't set.
         $publishTarget = Config::get('vividstore.productPublishTarget');
         if ($publishTarget < 1 || empty($publishTarget)) {
             //if not, install the proudct detail page if needed.
             $productParentPage = Page::getByPath('/product-detail');
             if ($productParentPage->isError()) {
                 $home = Page::getByID(HOME_CID);
                 $pageType = PageType::getByHandle('page');
                 $pageTemplate = PageTemplate::getByHandle('full');
                 $productParentPage = $home->add($pageType, array('cName' => t('Product Detail'), 'cHandle' => 'product-detail', 'pkgID' => $pkg->pkgID), $pageTemplate);
                 Page::getByPath('/product-detail')->setAttribute('exclude_nav', 1);
             }
             //set the config to publish under the new page.
             Config::save('vividstore.productPublishTarget', $productParentPage->getCollectionID());
         }
         /*
          * 3. Install Product Block
          */
         $productBlock = BlockType::getByHandle("vivid_product");
         if (!is_object($productBlock)) {
             BlockType::installBlockTypeFromPackage('vivid_product', $pkg);
         }
         /*
          * 3. Install Product PageType Defaults
          */
         $pageType = PageType::getByHandle('store_product');
         $template = $pageType->getPageTypeDefaultPageTemplateObject();
         $pageObj = $pageType->getPageTypePageTemplateDefaultPageObject($template);
         $bt = BlockType::getByHandle('vivid_product');
         $blocks = $pageObj->getBlocks('Main');
         if ($blocks[0] && $blocks[0]->getBlockTypeHandle() == "content") {
             $blocks[0]->deleteBlock();
         }
         if (count($blocks) < 1) {
             $data = array('productLocation' => 'page', 'showProductName' => 1, 'showProductDescription' => 1, 'showProductDetails' => 1, 'showProductPrice' => 1, 'showImage' => 1, 'showCartButton' => 1, 'showGroups' => 1);
             $pageObj->addBlock($bt, 'Main', $data);
         }
         /*
          * 5. Measurement Units.
          */
         $sizeUnits = Config::get('vividstore.sizeUnit');
         if (empty($sizeUnits)) {
             Config::save('vividstore.sizeUnit', 'in');
         }
         $weightUnits = Config::get('vividstore.weightUnit');
         if (empty($weightUnits)) {
             Config::save('vividstore.weightUnit', 'lb');
         }
         /*
          * 6. Fileset for digital downloads
          */
         $fs = FileSet::getByName('Digital Downloads');
         if (!is_object($fs)) {
             FileSet::add("Digital Downloads");
         }
         /*
          * 7. Product Attributes page
          */
         $attrPage = Page::getByPath('/dashboard/store/products/attributes');
         if (!is_object($attrPage) || $attrPage->isError()) {
             SinglePage::add('/dashboard/store/products/attributes', $pkg);
         }
         /*
          *  Add email order attribute
          */
         $text = AttributeType::getByHandle('text');
         $oakc = AttributeKeyCategory::getByHandle('store_order');
         $orderCustSet = AttributeSet::getByHandle('order_customer');
         $email = StoreOrderKey::getByHandle('email');
         if (!is_object($email)) {
             StoreOrderKey::add($text, array('akHandle' => 'email', 'akName' => t('Email')), $pkg)->setAttributeSet($orderCustSet);
         }
         // convert legacy config items to current config storage
         // applies for version 2.1.1 and below
         $db = Database::get();
         $configitems = $db->GetAll("SELECT * FROM Config WHERE configGroup='vividstore'");
         if (!empty($configitems)) {
             foreach ($configitems as $config) {
                 Config::save('vividstore.' . $config['configItem'], $config['configValue']);
             }
             $db->Execute("DELETE FROM Config WHERE configGroup='vividstore'");
         }
     }
     Installer::addOrderStatusesToDatabase($pkg);
     $paypalPM = PaymentMethod::getByHandle('paypal_standard');
     if (!is_object($paypalPM)) {
         PaymentMethod::add('paypal_standard', 'PayPal Standard', $pkg);
     }
     $co = Config::get('vividstore.cartOverlay');
     if (empty($co)) {
         Config::save('vividstore.cartOverlay', false);
     }
     parent::upgrade();
 }
Пример #4
0
 public static function installOrderAttributes(Package $pkg)
 {
     //create custom attribute category for orders
     $oakc = AttributeKeyCategory::getByHandle('store_order');
     if (!is_object($oakc)) {
         $oakc = AttributeKeyCategory::add('store_order', AttributeKeyCategory::ASET_ALLOW_SINGLE, $pkg);
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('text'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('textarea'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('number'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('address'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('boolean'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('date_time'));
         $orderCustSet = $oakc->addSet('order_customer', t('Store Customer Info'), $pkg);
     }
     $text = AttributeType::getByHandle('text');
     $address = AttributeType::getByHandle('address');
     Installer::installOrderAttribute('email', $text, $pkg, $orderCustSet);
     Installer::installOrderAttribute('billing_first_name', $text, $pkg, $orderCustSet);
     Installer::installOrderAttribute('billing_last_name', $text, $pkg, $orderCustSet);
     Installer::installOrderAttribute('billing_address', $address, $pkg, $orderCustSet);
     Installer::installOrderAttribute('billing_phone', $text, $pkg, $orderCustSet);
     Installer::installOrderAttribute('shipping_first_name', $text, $pkg, $orderCustSet);
     Installer::installOrderAttribute('shipping_last_name', $text, $pkg, $orderCustSet);
     Installer::installOrderAttribute('shipping_address', $address, $pkg, $orderCustSet);
 }