/** * Localize attributes of product. * * @param int $productUid Product uid * @param int $localizedProductUid Localized product uid * @param int $value Value * * @return void */ protected function translateAttributesOfProduct($productUid, $localizedProductUid, $value) { $database = $this->getDatabaseConnection(); // get all related attributes $productAttributes = $this->belib->getAttributesForProduct($productUid, false, true); // check if localized product has attributes $localizedProductAttributes = $this->belib->getAttributesForProduct($localizedProductUid); // Check product has attrinutes and no attributes are // avaliable for localized version if ($localizedProductAttributes == false && !empty($productAttributes)) { // if true $langIsoCode = BackendUtility::getRecord('sys_language', (int) $value, 'static_lang_isocode'); $langIdent = BackendUtility::getRecord('static_languages', (int) $langIsoCode['static_lang_isocode'], 'lg_typo3'); $langIdent = strtoupper($langIdent['lg_typo3']); foreach ($productAttributes as $productAttribute) { // only if we have attributes type 4 and no valuelist if ($productAttribute['uid_correlationtype'] == 4 && !$productAttribute['has_valuelist'] == 1) { $localizedProductAttribute = $productAttribute; unset($localizedProductAttribute['attributeData']); unset($localizedProductAttribute['has_valuelist']); switch (SettingsFactory::getInstance()->getExtConf('attributeLocalizationType')) { case self::ATTRIBUTE_LOCALIZATION_TITLE_EMPTY: unset($localizedProductAttribute['default_value']); break; case self::ATTRIBUTE_LOCALIZATION_TITLE_COPY: break; case self::ATTRIBUTE_LOCALIZATION_TITLE_PREPENDED: /* * Walk through the array and prepend text */ $prepend = '[Translate to ' . $langIdent . ':] '; $localizedProductAttribute['default_value'] = $prepend . $localizedProductAttribute['default_value']; break; default: } $localizedProductAttribute['uid_local'] = $localizedProductUid; $database->exec_INSERTquery('tx_commerce_products_attributes_mm', $localizedProductAttribute); } } /* * Update the flexform */ $resProduct = $database->exec_SELECTquery('attributesedit, attributes', 'tx_commerce_products', 'uid = ' . $productUid); if ($rowProduct = $database->sql_fetch_assoc($resProduct)) { $product['attributesedit'] = $this->belib->buildLocalisedAttributeValues($rowProduct['attributesedit'], $langIdent); $database->exec_UPDATEquery('tx_commerce_products', 'uid = ' . $localizedProductUid, $product); } } }
/** * Create a matrix of producible articles. * * @param array $parameter Parameter * @param FormEngine $fObj Form engine * * @return string A HTML-table with checkboxes and all needed stuff */ public function producibleArticles(array $parameter, FormEngine $fObj) { $this->uid = (int) $parameter['row']['uid']; $this->pid = (int) $parameter['row']['pid']; // get existing articles for this product, if they where not fetched yet if ($this->existingArticles == null) { $this->existingArticles = $this->belib->getArticlesOfProduct($this->uid); } // get all attributes for this product, if they where not fetched yet if ($this->attributes == null) { $this->attributes = $this->belib->getAttributesForProduct($this->uid, true, true, true); } $rowCount = $this->calculateRowCount(); if ($rowCount > 1000) { return sprintf($fObj->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_db.xml:tx_commerce_products.to_many_articles'), $rowCount); } // create the headrow from the product attributes, select attributes without // valuelist and normal select attributes $colCount = 0; $headRow = $this->getHeadRow($colCount, array(' ')); $valueMatrix = (array) $this->getValues(); $counter = 0; $resultRows = $fObj->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_db.xml:tx_commerce_products.create_warning'); $this->getRows($valueMatrix, $resultRows, $counter, $headRow); $emptyRow = '<tr><td><input type="checkbox" name="createList[empty]" /></td>'; $emptyRow .= '<td colspan="' . ($colCount - 1) . '">' . $fObj->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_db.xml:tx_commerce_products.empty_article') . '</td></tr>'; // create a checkbox for selecting all articles $selectJs = '<script language="JavaScript"> function updateArticleList() { var sourceSB = document.getElementById("selectAllArticles"); for (var i = 1; i <= ' . $rowCount . '; i++) { document.getElementById("createRow_" + i).checked = sourceSB.checked; } } </script>'; $selectAllRow = ''; if (!empty($valueMatrix)) { $onClick = 'onclick="updateArticleList()"'; $selectAllRow = '<tr><td><input type="checkbox" id="selectAllArticles" ' . $onClick . '/></td>'; $selectAllRow .= '<td colspan="' . ($colCount - 1) . '">' . $fObj->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_db.xml:tx_commerce_products.select_all_articles') . '</td></tr>'; } $result = '<table border="0">' . $selectJs . $headRow . $emptyRow . $selectAllRow . $resultRows . '</table>'; return $result; }