Beispiel #1
0
 /**
  * This function controls the buyer protection item in the basket.
  *
  * @param \Enlight_Controller_Action $controller
  * @param \Enlight_Controller_Request_RequestHttp $request
  * @param $basketAmount
  * @return void
  */
 private function controlBasketTsArticle($controller, $request, $basketAmount)
 {
     //get total basket amount
     $amount = $this->getAmount($controller->getShippingCosts(), $basketAmount);
     $basketArticle = $this->isTsArticleInBasket();
     //Always use the brutto-value
     if ($controller->View()->sAmountWithTax) {
         $amount = $controller->View()->sAmountWithTax;
     }
     if (empty($basketArticle)) {
         return;
     }
     $sql = "SELECT COUNT(id)\n\t\t\t\tFROM s_order_basket\n\t\t\t\tWHERE sessionID = ?\n\t\t\t\t\tAND modus = 0";
     $articleAmount = $this->db->fetchOne($sql, array($this->sessionId));
     if ($articleAmount > 1) {
         if ($amount > 0) {
             //get trusted shop article data
             $toAddArticle = $this->getTsArticleByAmount($amount);
             if ($toAddArticle['tsProductID'] == $basketArticle['ordernumber']) {
                 return;
             }
         }
     }
     $sql = "DELETE FROM s_order_basket\n\t\t\t\tWHERE id = ?\n\t\t\t\t\tAND sessionID = ?";
     $this->db->query($sql, array($basketArticle['id'], $this->sessionId));
     $controller->View()->sTsArticleRemoved = true;
     $controller->forward($request->getActionName());
 }
Beispiel #2
0
 /**
  * Create rewrite rules for articles
  *
  * @param string $lastUpdate
  * @param int $limit
  * @return string
  */
 public function sCreateRewriteTableArticles($lastUpdate, $limit = 1000)
 {
     $routerArticleTemplate = $this->config->get('sROUTERARTICLETEMPLATE');
     if (empty($routerArticleTemplate)) {
         return $lastUpdate;
     }
     $this->db->query('UPDATE `s_articles` SET `changetime`= NOW() WHERE `changetime`=?', array('0000-00-00 00:00:00'));
     $sql = $this->getSeoArticleQuery();
     $sql = $this->db->limit($sql, $limit);
     $result = $this->db->fetchAll($sql, array(Shopware()->Shop()->get('parentID'), Shopware()->Shop()->getId(), $lastUpdate));
     $result = $this->mapArticleTranslationObjectData($result);
     $result = Shopware()->Events()->filter('Shopware_Modules_RewriteTable_sCreateRewriteTableArticles_filterArticles', $result, array('shop' => Shopware()->Shop()->getId()));
     foreach ($result as $row) {
         $this->data->assign('sArticle', $row);
         $path = $this->template->fetch('string:' . $routerArticleTemplate, $this->data);
         $path = $this->sCleanupPath($path, false);
         $orgPath = 'sViewport=detail&sArticle=' . $row['id'];
         $this->sInsertUrl($orgPath, $path);
         $lastUpdate = $row['changed'];
         $lastId = $row['id'];
     }
     if (!empty($lastId)) {
         $this->db->query('UPDATE s_articles
             SET changetime = DATE_ADD(changetime, INTERVAL 1 SECOND)
             WHERE changetime=?
             AND id > ?', array($lastUpdate, $lastId));
     }
     return $lastUpdate;
 }
Beispiel #3
0
 /**
  * If the user confirm the order, this function sends the buyer protection request
  *
  * @param \Enlight_Event_EventArgs $args
  */
 public function onSaveOrder(\Enlight_Event_EventArgs $args)
 {
     /* @var \sOrder $orderSubject */
     $orderSubject = $args->getSubject();
     $shopId = $orderSubject->sSYSTEM->sSubShop['id'];
     if ($this->isShopware50) {
         $shopContext = Shopware()->Container()->get('shopware_storefront.context_service')->getShopContext();
         $shopId = $shopContext->getShop()->getId();
     }
     $article = $this->isTsArticleInOrder($orderSubject);
     if (!empty($article)) {
         $config = $this->tsConfig->getTrustedShopBasicConfig($shopId);
         $returnValue = $this->tsSoapApi->sendBuyerProtectionRequest($orderSubject, $article['ordernumber'], $shopId);
         if (is_int($returnValue) && $returnValue > 0) {
             /*
              * Inserts the order to the trusted shops order table
              * The Status will be updated in the cronjob onRunTSCheckOrderState
              * Status Description:
              * Status 0 Pending
              * Status 1 Success
              * Status 3 Error
              */
             $sql = "INSERT INTO `s_plugin_swag_trusted_shops_excellence_orders`\n\t\t\t\t\t\t(`ordernumber`, `shop_id`, `ts_applicationId`, `status`)\n\t\t\t\t\t\tVALUES (?,?,?,0)";
             $this->db->query($sql, array($orderSubject->sOrderNumber, $shopId, $returnValue));
             $comment = $config['stateWaiting']['description'];
             $status = $config['stateWaiting']['id'];
         } else {
             //failed
             $comment = $config['stateError']['description'];
             $status = $config['stateError']['id'];
         }
         $sql = "UPDATE s_order\n\t\t\t\t\tSET internalcomment = ?, status = ?\n\t\t\t\t\tWHERE ordernumber = ?";
         $this->db->query($sql, array($comment, $status, $orderSubject->sOrderNumber));
     }
 }
Beispiel #4
0
 /**
  * Clear search cache
  */
 public function clearSearchCache()
 {
     $sql = "SELECT `id` FROM `s_core_config_elements` WHERE `name` LIKE 'fuzzysearchlastupdate'";
     $elementId = $this->db->fetchOne($sql);
     $sql = 'DELETE FROM s_core_config_values WHERE element_id=?';
     $this->db->query($sql, array($elementId));
 }
Beispiel #5
0
 private function deleteProperties($namePrefix = 'Test')
 {
     $this->db->query("DELETE FROM s_filter WHERE name = '" . $namePrefix . "-Set'");
     $ids = $this->db->fetchCol("SELECT id FROM s_filter_options WHERE name LIKE '" . $namePrefix . "-Gruppe%'");
     foreach ($ids as $id) {
         $this->db->query("DELETE FROM s_filter_options WHERE id = ?", array($id));
         $this->db->query("DELETE FROM s_filter_relations WHERE optionID = ?", array($id));
     }
     $this->db->query("DELETE FROM s_filter_values WHERE value LIKE '" . $namePrefix . "-Option%'");
 }
Beispiel #6
0
 /**
  * generates a new attribute for the articles to
  * mark Trusted Shops articles
  */
 private function generateAttribute()
 {
     $this->em->addAttribute('s_articles_attributes', 'swag', 'is_trusted_shops_article', 'tinyint(1)', true, 0);
     $this->em->addAttribute('s_articles_attributes', 'swag', 'trusted_range', 'int(11)', true, null);
     $this->em->addAttribute('s_articles_attributes', 'swag', 'trusted_duration', 'varchar(20)', true, null);
     $this->em->generateAttributeModels(array('s_articles_attributes'));
     try {
         $sql = "CREATE INDEX swag_trusted_range ON s_articles_attributes (swag_trusted_range);";
         $this->db->query($sql);
     } catch (Exception $e) {
     }
 }
 /**
  * @param int $articleId
  * @param int $categoryId
  */
 public function assignArticlesToCategory($articleId, $categoryId)
 {
     $categoryId = intval($categoryId);
     $articleId = intval($articleId);
     if (empty($categoryId) || empty($articleId)) {
         return;
     }
     $sql = "INSERT IGNORE INTO s_articles_categories (articleID, categoryID)\n                SELECT {$articleId} as articleID, c.id as categoryID\n                FROM s_categories c\n                WHERE c.id IN ({$categoryId})";
     if ($this->db->query($sql) === false) {
         return;
     }
     $categoryDenormalization = Shopware()->Container()->get('categorydenormalization');
     $categoryDenormalization->addAssignment($articleId, $categoryId);
     $categoryDenormalization->disableTransactions();
 }
Beispiel #8
0
    /**
     * Assigns the next CustomerNumber from s_order_number
     * to given $userId and updates s_order_number
     * in an atomic operation.
     *
     * @param int $userId
     */
    private function assignCustomerNumber($userId)
    {
        $sql = <<<SQL
UPDATE
    s_order_number,
    s_user_billingaddress
SET
    s_order_number.number = s_order_number.number+1,
    s_user_billingaddress.customernumber = s_order_number.number
WHERE
    s_order_number.name = 'user'
AND
    s_user_billingaddress.userID = ?
SQL;
        $this->db->query($sql, array($userId));
    }
Beispiel #9
0
 /**
  * Helper function for sAdmin::sGetUserData()
  * Gets user billing data
  *
  * @param $userId
  * @param $userData
  * @return mixed
  */
 private function getUserBillingData($userId, $userData)
 {
     $billing = $this->db->fetchRow('SELECT * FROM s_user_billingaddress WHERE userID = ?', array($userId));
     $billing = $billing ?: array();
     $builder = Shopware()->Models()->createQueryBuilder();
     $attributes = $builder->select(array('attributes'))->from('Shopware\\Models\\Attribute\\CustomerBilling', 'attributes')->innerJoin('attributes.customerBilling', 'billing')->where('billing.customerId = :userId')->setParameter('userId', $userId)->setFirstResult(0)->setMaxResults(1)->getQuery()->getOneOrNullResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);
     if (!is_array($attributes)) {
         $attributes = array();
     } else {
         unset($attributes['id']);
     }
     $userData["billingaddress"] = array_merge($attributes, $billing);
     if (empty($userData["billingaddress"]['customernumber']) && $this->config->get('sSHOPWAREMANAGEDCUSTOMERNUMBERS')) {
         $this->db->query("UPDATE s_order_number, s_user_billingaddress\n                SET s_order_number.number = s_order_number.number+1,\n                s_user_billingaddress.customernumber = s_order_number.number+1\n                WHERE s_order_number.name = 'user'\n                AND s_user_billingaddress.userID = ?", array($userId));
         return $userData;
     }
     return $userData;
 }
 /**
  * @return array|string
  * @throws \Zend_Db_Statement_Exception
  */
 public function getAttributes()
 {
     $stmt = $this->db->query("SHOW COLUMNS FROM s_categories_attributes");
     $columns = $stmt->fetchAll();
     $attributes = $this->getFieldNames($columns);
     $attributesSelect = '';
     if ($attributes) {
         $prefix = 'attr';
         $attributesSelect = array();
         foreach ($attributes as $attribute) {
             //underscore to camel case
             //exmaple: underscore_to_camel_case -> underscoreToCamelCase
             $catAttr = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute))));
             $attributesSelect[] = sprintf('%s.%s as attribute%s', $prefix, $catAttr, ucwords($catAttr));
         }
     }
     return $attributesSelect;
 }
 /**
  * @param string $tableName
  * @param string $columnName
  * @param string $prefixField
  * @param string $prefixSelect
  * @return array
  */
 public function getAttributesFieldsByTableName($tableName, $columnName, $prefixField, $prefixSelect)
 {
     $stmt = $this->db->query("SHOW COLUMNS FROM {$tableName}");
     $columns = $stmt->fetchAll();
     $columnNames = [];
     foreach ($columns as $column) {
         if ($column['Field'] !== 'id' && $column['Field'] != $columnName) {
             $columnNames[] = $column['Field'];
         }
     }
     $attributesSelect = [];
     foreach ($columnNames as $attribute) {
         //underscore to camel case
         //exmaple: underscore_to_camel_case -> underscoreToCamelCase
         $attribute = str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute)));
         $attributesSelect[] = sprintf('%s.%s as %s%s', $prefixField, lcfirst($attribute), $prefixSelect, $attribute);
     }
     return $attributesSelect;
 }
 /**
  * @param array $article
  * @param array $defaultValues
  * @return ArticleWriterResult
  * @throws AdapterException
  */
 protected function insertOrUpdateArticle($article, $defaultValues)
 {
     $shouldCreateMainArticle = false;
     list($mainDetailId, $articleId, $detailId) = $this->findExistingEntries($article);
     if ($article['processed']) {
         if (!$mainDetailId) {
             $mainDetailId = $detailId;
         }
         return new ArticleWriterResult($articleId, $detailId, $mainDetailId);
     }
     $createDetail = $detailId == 0;
     // if detail needs to be created and the (different) mainDetail does not exist: error
     if ($createDetail && !$mainDetailId && !$this->isMainDetail($article)) {
         $message = SnippetsHelper::getNamespace()->get('adapters/articles/variant_existence', 'Variant with number %s does not exists.');
         throw new AdapterException(sprintf($message, $article['mainNumber']));
     }
     // Set create flag
     if ($createDetail && $this->isMainDetail($article)) {
         $shouldCreateMainArticle = true;
         $article = $this->dataManager->setDefaultFieldsForCreate($article, $defaultValues);
         $this->validator->checkRequiredFieldsForCreate($article);
     }
     $article = $this->dataManager->setDefaultFields($article);
     $this->validator->validate($article, ArticleDataType::$mapper);
     $article = $this->dataManager->setArticleData($article, ArticleDataType::$articleFieldsMapping);
     // insert/update main detail article
     if ($this->isMainDetail($article)) {
         $articleId = $this->createOrUpdateMainDetail($article, $shouldCreateMainArticle, $articleId);
     }
     $article['articleId'] = $articleId;
     $article['kind'] = $mainDetailId == $detailId ? 1 : 2;
     list($article, $detailId) = $this->createOrUpdateArticleDetail($article, $defaultValues, $detailId, $createDetail);
     // set reference
     if ($shouldCreateMainArticle) {
         $this->db->query('UPDATE s_articles SET main_detail_id = ? WHERE id = ?', array($detailId, $articleId));
     }
     // insert attributes
     $this->createArticleAttributes($article, $articleId, $detailId, $shouldCreateMainArticle);
     if (!$mainDetailId) {
         $mainDetailId = $detailId;
     }
     return new ArticleWriterResult($articleId, $mainDetailId, $detailId);
 }
 /**
  * @param array $customer
  * @return array
  */
 private function newsletterSubscribe(array $customer)
 {
     if (!isset($customer['newsletter'])) {
         return $customer;
     }
     if (empty($customer['newsletter'])) {
         $sql = 'DELETE FROM S_CAMPAIGNS_MAILADDRESSES
                 WHERE EMAIL = ' . $customer['email'];
         $this->db->query($sql);
     } else {
         $customer['newslettergroupID'] = $this->getNewsletterGroupId($customer['newslettergroupID']);
         $sql = 'SELECT ID
                 FROM S_CAMPAIGNS_MAILADDRESSES
                 WHERE EMAIL = ' . $customer['email'];
         $result = $this->db->fetchOne($sql);
         if (empty($result)) {
             $sql = "INSERT INTO s_campaigns_mailaddresses (customer, groupID, email)\n                        VALUES (1, {$customer['newslettergroupID']}, {$customer['email']});";
             $this->db->query($sql);
         }
     }
     return $customer;
 }
    /**
     * This function updates the Database.
     * First it adds two columns, one in the s_core_config_mails and one in the s_core_optin table. This is
     * necessary because those tables were changed in SW 5.0.4.
     * Than it implements the new password restore E-Mail Template
     *
     * @return boolean
     */
    public function updateDb()
    {
        $sql = "ALTER TABLE `s_core_optin` ADD `type` VARCHAR(255) NULL DEFAULT '' AFTER `id`";
        $this->db->query($sql);
        $sql = <<<'EOD'
INSERT IGNORE INTO `s_core_config_mails` (`id`, `stateId`, `name`, `frommail`, `fromname`, `subject`, `content`, `contentHTML`, `ishtml`, `attachment`, `mailtype`, `context`) VALUES (NULL, NULL, 'sPLUGCONFIRMPASSWORDCHANGE', '{config name=mail}', '{config name=shopName}', 'Passwort vergessen - Passwort zurücksetzen', '{include file=\"string:{config name=emailheaderplain}\"}\r\n\r\nHallo,

im Shop {sShopURL} wurde eine Anfrage gestellt, um Ihr Passwort zurück zu setzen.

Bitte bestätigen Sie den unten stehenden Link, um ein neues Passwort zu definieren.

{sUrlReset}

Dieser Link ist nur für die nächsten 2 Stunden gültig. Danach muss das Zurücksetzen des Passwortes erneut beantragt werden.

Falls Sie Ihr Passwort nicht zurücksetzen möchten, ignorieren Sie diese E-Mail - es wird dann keine Änderung vorgenommen.

{config name=address}\r\n\r\n{include file=\"string:{config name=emailfooterplain}\"}', '', '0', '', '2', '');
EOD;
        $this->db->query($sql);
        return true;
    }
 private function insertDefaultDocuments()
 {
     $sql = "\n\t\t\tINSERT INTO `s_core_documents_box` (`documentID`, `name`, `style`, `value`) VALUES\n\t\t\t(1, 'Paypal_Footer', 'width: 170mm;\r\nposition:fixed;\r\nbottom:-20mm;\r\nheight: 15mm;', ?),\n\t\t\t(1, 'Paypal_Content_Info', ?, ?);\n\t\t";
     $this->databaseConnection->query($sql, array('<table style="height: 90px;" border="0" width="100%">' . '<tbody>' . '<tr valign="top">' . '<td style="width: 33%;">' . '<p><span style="font-size: xx-small;">Demo GmbH</span></p>' . '<p><span style="font-size: xx-small;">Steuer-Nr: <br/>UST-ID: <br/>Finanzamt </span><span style="font-size: xx-small;">Musterstadt</span></p>' . '</td>' . '<td style="width: 33%;">' . '<p><span style="font-size: xx-small;">AGB<br /></span></p>' . '<p><span style="font-size: xx-small;">Gerichtsstand ist Musterstadt<br />Erf&uuml;llungsort Musterstadt</span></p>' . '</td>' . '<td style="width: 33%;">' . '<p><span style="font-size: xx-small;">Gesch&auml;ftsf&uuml;hrer</span></p>' . '<p><span style="font-size: xx-small;">Max Mustermann</span></p>' . '</td>' . '</tr>' . '</tbody>' . '</table>', '.payment_instruction, .payment_instruction td, .payment_instruction tr {' . '	margin: 0;' . '	padding: 0;' . '	border: 0;' . '	font-size:8px;' . '	font: inherit;' . '	vertical-align: baseline;' . '}' . '.payment_note {' . '	font-size: 10px;' . '	color: #333;' . '}', '<div class="payment_note">' . '<br />' . 'Demo GmbH hat die Forderung gegen Sie im Rahmen eines laufenden Factoringvertrages an die PayPal (Europe) S.àr.l. et Cie, S.C.A. abgetreten. Zahlungen mit schuldbefreiender Wirkung können nur an die PayPal (Europe) S.àr.l. et Cie, S.C.A. geleistet werden.' . '<br /><br />' . 'Bitte überweisen Sie {$instruction.amount_value|currency} bis {$instruction.payment_due_date|date_format: "%d.%m.%Y"} an PayPal.' . '<br /><br />' . '</div>' . '<table class="payment_instruction">' . '<tbody>' . '<tr>' . '<td>Empf&auml;nger:</td>' . '<td>{$instruction.account_holder_name}</td>' . '</tr>' . '<tr>' . '<td>IBAN:</td>' . '<td>{$instruction.international_bank_account_number}</td>' . '</tr>' . '<tr>' . '<td>BIC:</td>' . '<td>{$instruction.bank_identifier_code}</td>' . '</tr>' . '<tr>' . '<td>Bank:</td>' . '<td>{$instruction.bank_name}</td>' . '</tr>' . '<tr>' . '<td>Betrag:</td>' . '<td>{$instruction.amount_value}&nbsp;{$instruction.amount_currency}</td>' . '</tr>' . '<tr>' . '<td>Verwendungszweck:</td>' . '<td>{$instruction.reference_number}</td>' . '</tr>' . '</tbody>' . '</table>'));
 }
 /**
  * @param int $articleId
  * @param int $setId
  */
 protected function updateArticleSetsRelation($articleId, $setId)
 {
     $this->db->query('UPDATE s_articles SET configurator_set_id = ? WHERE id = ?', array($setId, $articleId));
 }
Beispiel #17
0
 /**
  * executes the current product export
  *
  * @param resource $handleResource used as a file or the stdout to fetch the smarty output
  */
 public function executeExport($handleResource)
 {
     fwrite($handleResource, $this->sSmarty->fetch('string:' . $this->sSettings['header'], $this->sFeedID));
     $context = $this->contextService->getShopContext();
     $sql = $this->sCreateSql();
     $result = $this->db->query($sql);
     if ($result === false) {
         return;
     }
     // Update db with the latest values
     $count = (int) $result->rowCount();
     $this->db->update('s_export', array('last_export' => new Zend_Date(), 'cache_refreshed' => new Zend_Date(), 'count_articles' => $count), array('id = ?' => $this->sFeedID));
     // fetches all required data to smarty
     $rows = array();
     for ($rowIndex = 1; $row = $result->fetch(); $rowIndex++) {
         if (!empty($row['group_ordernumber_2'])) {
             $row['group_ordernumber'] = $this->_decode_line($row['group_ordernumber_2']);
             $row['group_pricenet'] = explode(';', $row['group_pricenet_2']);
             $row['group_price'] = explode(';', $row['group_price_2']);
             $row['group_instock'] = explode(';', $row['group_instock_2']);
             $row['group_active'] = explode(';', $row['group_active_2']);
             unset($row['group_ordernumber_2'], $row['group_pricenet_2']);
             unset($row['group_price_2'], $row['group_instock_2'], $row['group_active_2']);
             for ($i = 1; $i <= 10; $i++) {
                 if (!empty($row['group_group' . $i])) {
                     $row['group_group' . $i] = $this->_decode_line($row['group_group' . $i]);
                 } else {
                     unset($row['group_group' . $i]);
                 }
                 if (!empty($row['group_option' . $i])) {
                     $row['group_option' . $i] = $this->_decode_line($row['group_option' . $i]);
                 } else {
                     unset($row['group_option' . $i]);
                 }
             }
             unset($row['group_additionaltext']);
         } elseif (!empty($row['group_ordernumber'])) {
             $row['group_ordernumber'] = $this->_decode_line($row['group_ordernumber']);
             $row['group_additionaltext'] = $this->_decode_line($row['group_additionaltext']);
             $row['group_pricenet'] = explode(';', $row['group_pricenet']);
             $row['group_price'] = explode(';', $row['group_price']);
             $row['group_instock'] = explode(';', $row['group_instock']);
             $row['group_active'] = explode(';', $row['group_active']);
         }
         if (!empty($row['article_translation_fallback'])) {
             $translation = $this->sMapTranslation('article', $row['article_translation_fallback']);
             if ($row['main_detail_id'] != $row['articledetailsID']) {
                 unset($translation['additionaltext']);
             }
             $row = array_merge($row, $translation);
         }
         if (!empty($row['article_translation'])) {
             $translation = $this->sMapTranslation('article', $row['article_translation']);
             if ($row['main_detail_id'] != $row['articledetailsID']) {
                 unset($translation['additionaltext']);
             }
             $row = array_merge($row, $translation);
         }
         if (!empty($row['detail_translation_fallback'])) {
             $translation = $this->sMapTranslation('detail', $row['detail_translation_fallback']);
             $row = array_merge($row, $translation);
         }
         if (!empty($row['detail_translation'])) {
             $translation = $this->sMapTranslation('detail', $row['detail_translation']);
             $row = array_merge($row, $translation);
         }
         $row['name'] = htmlspecialchars_decode($row['name']);
         $row['supplier'] = htmlspecialchars_decode($row['supplier']);
         //cast it to float to prevent the division by zero warning
         $row['purchaseunit'] = floatval($row['purchaseunit']);
         $row['referenceunit'] = floatval($row['referenceunit']);
         if (!empty($row['purchaseunit']) && !empty($row['referenceunit'])) {
             $row['referenceprice'] = Shopware()->Modules()->Articles()->calculateReferencePrice($row['price'], $row['purchaseunit'], $row['referenceunit']);
         }
         if ($row['configurator'] > 0) {
             if (empty($this->sSettings["variant_export"]) || $this->sSettings["variant_export"] == 1) {
                 $row['group_additionaltext'] = array();
                 if (!empty($row['group_ordernumber'])) {
                     foreach ($row['group_ordernumber'] as $orderNumber) {
                         $product = new StoreFrontBundle\Struct\ListProduct((int) $row['articleID'], (int) $row["articledetailsID"], $orderNumber);
                         $product->setAdditional($row['additionaltext']);
                         $product = $this->additionalTextService->buildAdditionalText($product, $context);
                         if (array_key_exists($orderNumber, $row['group_additionaltext'])) {
                             $row['group_additionaltext'][$orderNumber] = $product->getAdditional();
                         }
                         if ($orderNumber == $row['ordernumber']) {
                             $row['additionaltext'] = $product->getAdditional();
                         }
                     }
                 }
             }
             $product = new StoreFrontBundle\Struct\ListProduct((int) $row['articleID'], (int) $row["articledetailsID"], $row['ordernumber']);
             $product->setAdditional($row['additionaltext']);
             $product = $this->additionalTextService->buildAdditionalText($product, $context);
             $row['additionaltext'] = $product->getAdditional();
         }
         $rows[] = $row;
         if ($rowIndex == $count || count($rows) >= 50) {
             @set_time_limit(30);
             $this->sSmarty->assign('sArticles', $rows);
             $rows = array();
             $template = 'string:{foreach $sArticles as $sArticle}' . $this->sSettings['body'] . '{/foreach}';
             fwrite($handleResource, $this->sSmarty->fetch($template, $this->sFeedID));
         }
     }
     fwrite($handleResource, $this->sSmarty->fetch('string:' . $this->sSettings['footer'], $this->sFeedID));
     fclose($handleResource);
 }
 /**
  * @param $ids
  * @return array
  * @throws \Zend_Db_Statement_Exception
  */
 public function getTranslations($ids)
 {
     $translationIds = implode(',', $ids);
     $sql = "\n            (SELECT ad.id as id, ad.ordernumber as articleNumber, ad.kind as kind,\n                    t.objectdata as articleData, t.objectdata as variantData, t.objectlanguage as languageId\n            FROM s_core_translations t\n            LEFT JOIN s_articles a ON (t.objectkey = a.id)\n            LEFT JOIN s_articles_details ad ON (ad.articleID = a.id AND ad.kind = 1)\n            WHERE t.id IN ({$translationIds}) AND t.objecttype = 'article')            \n            \n            UNION\n            \n            (SELECT  ad.id as id, ad.ordernumber as articleNumber, ad.kind as kind,\n                    t.objectdata as articleData, t.objectdata as variantData, t.objectlanguage as languageId\n            FROM s_core_translations t\n            LEFT JOIN s_articles_details ad ON (t.objectkey = ad.id)\n            WHERE t.id IN ({$translationIds}) AND t.objecttype = 'variant')\n            \n            ORDER BY languageId ASC\n        ";
     return $this->db->query($sql)->fetchAll();
 }
 /**
  * Updates/Creates relation between articles and property groups
  *
  * @param int|string $filterGroupId
  * @param int|string $articleId
  */
 private function updateGroupsRelation($filterGroupId, $articleId)
 {
     $this->db->query('UPDATE s_articles SET filtergroupID = ? WHERE id = ?', [$filterGroupId, $articleId]);
 }
Beispiel #20
0
 /**
  * Uninstall method of the plugin. The plugin database table will be dropped.
  *
  * @return bool
  */
 public function uninstall()
 {
     $sql = 'DROP TABLE IF EXISTS `s_plugin_migrations`;';
     $this->db->query($sql);
     return parent::uninstall();
 }
 public function installAdditionalDatabaseTable()
 {
     $sql = $this->getSql();
     return $this->databaseConnection->query($sql);
 }
 /**
  * @param int $articleID
  * @return bool
  */
 private function deletePermissions($articleID)
 {
     $sql = ' DELETE FROM s_articles_avoid_customergroups WHERE articleID = ?';
     $this->db->query($sql, [$articleID]);
     return true;
 }
 /**
  * @param string $orderNumber
  * @param array $instructions
  */
 public function saveInstructionByOrderNumber($orderNumber, array $instructions)
 {
     $parameter = array('ordernumber' => $orderNumber, 'reference_number' => $instructions['reference_number'], 'instruction_type' => $instructions['instruction_type'], 'bank_name' => $instructions['recipient_banking_instruction']['bank_name'], 'account_holder_name' => $instructions['recipient_banking_instruction']['account_holder_name'], 'international_bank_account_number' => $instructions['recipient_banking_instruction']['international_bank_account_number'], 'bank_identifier_code' => $instructions['recipient_banking_instruction']['bank_identifier_code'], 'amount_value' => $instructions['amount']['value'], 'amount_currency' => $instructions['amount']['currency'], 'payment_due_date' => $instructions['payment_due_date'], 'links' => json_encode($instructions['links']));
     $this->db->query($this->getInsertSql(), $parameter);
 }
Beispiel #24
0
 /**
  * Add product to cart
  * Used in multiple locations
  *
  * @param int $id Order number (s_articles_details.ordernumber)
  * @param int $quantity Amount
  * @throws Enlight_Exception If no price could be determined, or a database error occurs
  * @return int|false Id of the inserted basket entry, or false on failure
  */
 public function sAddArticle($id, $quantity = 1)
 {
     $sessionId = $this->session->get('sessionId');
     if ($this->session->get('Bot') || empty($sessionId)) {
         return false;
     }
     $quantity = empty($quantity) || !is_numeric($quantity) ? 1 : (int) $quantity;
     if ($quantity <= 0) {
         $quantity = 1;
     }
     if ($this->eventManager->notifyUntil('Shopware_Modules_Basket_AddArticle_Start', array('subject' => $this, 'id' => $id, "quantity" => $quantity))) {
         return false;
     }
     $article = $this->getArticleForAddArticle($id);
     if (!$article) {
         return false;
     }
     $chkBasketForArticle = $this->checkIfArticleIsInBasket($article["articleID"], $article["ordernumber"], $sessionId);
     // Shopware 3.5.0 / sth / laststock - instock check
     if (!empty($chkBasketForArticle["id"])) {
         if ($article["laststock"] == true && $article["instock"] < $chkBasketForArticle["quantity"] + $quantity) {
             $quantity -= $chkBasketForArticle["quantity"];
         }
     } else {
         if ($article["laststock"] == true && $article["instock"] <= $quantity) {
             $quantity = $article["instock"];
             if ($quantity <= 0) {
                 return;
             }
         }
     }
     if ($chkBasketForArticle) {
         // Article is already in basket, update quantity
         $quantity += $chkBasketForArticle["quantity"];
         $this->sUpdateArticle($chkBasketForArticle["id"], $quantity);
         return $chkBasketForArticle["id"];
     }
     $price = $this->getPriceForAddArticle($article);
     // For variants, extend the article name
     if ($article["additionaltext"]) {
         $article["articleName"] .= " " . $article["additionaltext"];
     }
     if (!$article["shippingfree"]) {
         $article["shippingfree"] = "0";
     }
     // Check if article is an esd-article
     // - add flag to basket
     $getEsd = $this->db->fetchOne('SELECT s_articles_esd.id AS id, serials
         FROM s_articles_esd, s_articles_details
         WHERE s_articles_esd.articleID = ?
         AND s_articles_esd.articledetailsID = s_articles_details.id
         AND s_articles_details.ordernumber = ?', array($article["articleID"], $article["ordernumber"]));
     $sEsd = $getEsd ? '1' : '0';
     $quantity = (int) $quantity;
     $sql = "\n            INSERT INTO s_order_basket (id, sessionID, userID, articlename, articleID,\n                ordernumber, shippingfree, quantity, price, netprice,\n                datum, esdarticle, partnerID, config)\n            VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )\n        ";
     $params = array('', (string) $sessionId, (string) $this->session->get('sUserId'), $article["articleName"], $article["articleID"], (string) $article["ordernumber"], $article["shippingfree"], $quantity, $price["price"], $price["netprice"], date("Y-m-d H:i:s"), $sEsd, (string) $this->session->get('sPartner'), '');
     $sql = $this->eventManager->filter('Shopware_Modules_Basket_AddArticle_FilterSql', $sql, array('subject' => $this, 'article' => $article, 'price' => $price, 'esd' => $sEsd, 'quantity' => $quantity, 'partner' => $this->session->get('sPartner')));
     $result = $this->db->query($sql, $params);
     if (!$result) {
         throw new Enlight_Exception("BASKET-INSERT #02 SQL-Error" . $sql);
     }
     $insertId = $this->db->lastInsertId();
     $this->db->insert('s_order_basket_attributes', array('basketID' => $insertId, 'attribute1' => ''));
     $this->sUpdateArticle($insertId, $quantity);
     return $insertId;
 }
 private function insertDefaultDocuments()
 {
     $sql = "\n\t\t\tINSERT INTO `s_core_documents_box` (`documentID`, `name`, `style`, `value`) VALUES\n\t\t\t(1, 'Paypal_Footer', 'width: 170mm;\r\nposition:fixed;\r\nbottom:-20mm;\r\nheight: 15mm;', ?),\n\t\t\t(1, 'Paypal_Content_Info', ?, ?);\n\t\t";
     $this->databaseConnection->query($sql, array('<table style="height: 90px;" border="0" width="100%">' . '<tbody>' . '<tr valign="top">' . '<td style="width: 33%;">' . '<p><span style="font-size: xx-small;">Demo GmbH</span></p>' . '<p><span style="font-size: xx-small;">Steuer-Nr: <br/>UST-ID: <br/>Finanzamt </span><span style="font-size: xx-small;">Musterstadt</span></p>' . '</td>' . '<td style="width: 33%;">' . '<p><span style="font-size: xx-small;">AGB<br /></span></p>' . '<p><span style="font-size: xx-small;">Gerichtsstand ist Musterstadt<br />Erf&uuml;llungsort Musterstadt</span></p>' . '</td>' . '<td style="width: 33%;">' . '<p><span style="font-size: xx-small;">Gesch&auml;ftsf&uuml;hrer</span></p>' . '<p><span style="font-size: xx-small;">Max Mustermann</span></p>' . '</td>' . '</tr>' . '</tbody>' . '</table>', '.payment_instruction, .payment_instruction td, .payment_instruction tr {' . '	margin: 0;' . '	padding: 0;' . '	border: 0;' . '	font-size:8px;' . '	font: inherit;' . '	vertical-align: baseline;' . '}' . '.payment_note {' . '	font-size: 10px;' . '	color: #333;' . '}', '<div class="payment_note">' . '<br />' . 'Warum PayPal? Rechnunskauf ist ein Service für den wir mit PayPal zusammenarbeiten. Der Betrag wurde von PayPal soeben direkt an uns gezahlt. Sie bezahlen den Rechnungsbetrag gemäß den Zahlungshinweisen an PayPal, nachdem Sie die Ware erhalten und geprüft haben.' . '<br /><br />' . 'Bitte überweisen Sie {$instruction.amount_value|currency} bis {$instruction.payment_due_date|date_format: "%d.%m.%Y"} an PayPal.' . '<br /><br />' . '</div>' . '<table class="payment_instruction">' . '<tbody>' . '<tr>' . '<td>Empf&auml;nger:</td>' . '<td>{$instruction.account_holder_name}</td>' . '</tr>' . '<tr>' . '<td>IBAN:</td>' . '<td>{$instruction.international_bank_account_number}</td>' . '</tr>' . '<tr>' . '<td>BIC:</td>' . '<td>{$instruction.bank_identifier_code}</td>' . '</tr>' . '<tr>' . '<td>Bank:</td>' . '<td>{$instruction.bank_name}</td>' . '</tr>' . '<tr>' . '<td>Betrag:</td>' . '<td>{$instruction.amount_value}&nbsp;{$instruction.amount_currency}</td>' . '</tr>' . '<tr>' . '<td>Verwendungszweck:</td>' . '<td>{$instruction.reference_number}</td>' . '</tr>' . '</tbody>' . '</table>'));
 }