Compare commits

..

No commits in common. "master" and "rel_1.x" have entirely different histories.

12 changed files with 297 additions and 266 deletions

View File

@ -1,23 +0,0 @@
# Multiple value assignment to attributes
This package supports the multiple assignment of attribute values. This allows you to describe your articles in more detail and offer more flexible filters.
Instead of
* Colour: yellow
* Material: cotton
you can now maintain further details:
* Color: yellow
* Colour: black
* Material: cotton
* Material: Polyester
These additional filter options can be used in our [advanced search](https://packagist.org/packages/d3/extsearch) module, for example.
## Install
Run this composer statement in your shop. Adjust this command if your installation requires it.
```
composer require d3/attributemultivalues --update-no-dev
```

View File

@ -1,42 +0,0 @@
{
"name": "d3/attributemultivalues",
"description": "mehrfache Wertezuordnung zu Attributen",
"type": "oxideshop-module",
"keywords": [
"oxid",
"modules",
"eShop",
"d3"
],
"authors": [
{
"name": "D3 Data Development (Inh. Thomas Dartsch)",
"email": "info@shopmodule.com",
"homepage": "http://www.d3data.de",
"role": "Owner"
}
],
"homepage": "https://www.oxidmodule.com/",
"license": [
"proprietary"
],
"extra": {
"oxideshop": {
"source-directory": "/src",
"target-directory": "d3/attributemultivalues"
},
"patches": {
"oxid-esales/oxideshop-ce": {
"add multi assignment to article attribute ajax template - 2020-02-25-1": "https://git.d3data.de/D3Public/AttributeMultiValues/raw/branch/rel_2.x/patches/article_attribute_ajax.patch"
}
}
},
"require": {
"oxid-esales/oxideshop-ce": "6.1 - 6.3"
},
"autoload": {
"psr-4": {
"D3\\AttributeMultiValues\\": "../../../source/modules/d3/attributemultivalues"
}
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
/**
* Metadata version
*/
$sMetadataVersion = '1.1';
/**
* Module information
*/
$aModule = array(
'id' => 'd3multiattributevalues',
'title' => (class_exists('d3utils') ? d3utils::getInstance()->getD3Logo() : 'D&sup3;') . ' Mehrfachzuordnungen bei Attributen',
'description' => array(
'de' => '',
'en' => '',
),
'thumbnail' => 'picture.png',
'version' => 'indiv.',
'author' => 'D&sup3; Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com',
'url' => 'http://www.oxidmodule.com/',
'extend' => array(
'article_attribute_ajax' => 'd3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_ajax_multivalues',
'article_attribute' => 'd3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_multivalues',
'oxattributelist' => 'd3/d3multiattributevalues/modules/models/d3_oxattributelist_multivalues',
),
'files' => array(
),
'templates' => array(
'd3_article_attribute_multivalues.tpl' => 'd3/d3multiattributevalues/views/admin/tpl/d3_article_attribute_multivalues.tpl',
),
'events' => array(
'onActivate' => 'd3install::checkUpdateStart',
),
'settings' => array(
),
'blocks' => array(
),
'd3FileRegister' => array(
'd3/d3multilang/IntelliSenseHelper.php',
'd3/d3multilang/metadata.php',
'd3/d3multilang/views/admin/de/d3_multilang_lang.php',
'd3/d3multilang/views/admin/en/d3_multilang_lang.php',
'd3/d3multilang/views/admin/tpl/modcfg-pattern/oxid_lang_file.tpl',
),
);

View File

@ -0,0 +1,70 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright © D³ Data Development, Thomas Dartsch
* @author DÂł Data Development - Daniel Seifert <ds@shopmodule.com>
* @link http://www.oxidmodule.com
*/
class d3_article_attribute_ajax_multivalues extends d3_article_attribute_ajax_multivalues_parent
{
/**
* Returns SQL query for data to fetc
*
* @return string
*/
protected function _getQuery()
{
$sQAdd = parent::_getQuery();
$sArtId = oxRegistry::getConfig()->getRequestParameter('oxid');
if (false == $sArtId) {
$sAttrViewName = $this->_getViewName('oxattribute');
$sQAdd = " from {$sAttrViewName} where {$sAttrViewName}.oxid ";
}
return $sQAdd;
}
/**
* Saves attribute value
*/
public function saveAttributeValue()
{
$oDb = oxDb::getDb();
$soxId = oxRegistry::getConfig()->getRequestParameter("oxid");
$sAttributeId = oxRegistry::getConfig()->getRequestParameter("attr_oxid");
$sAttributeValue = oxRegistry::getConfig()->getRequestParameter("attr_value");
$sO2AttributeValue = $oDb->quote(oxRegistry::getConfig()->getRequestParameter("o2attr_oxid"));
if (!$this->getConfig()->isUtf()) {
$sAttributeValue = iconv('UTF-8', oxRegistry::getLang()->translateString("charset"), $sAttributeValue);
}
$oArticle = oxNew("oxarticle");
if ($oArticle->load($soxId)) {
if (isset($sAttributeId) && ("" != $sAttributeId)) {
$sViewName = $this->_getViewName("oxobject2attribute");
$sSelect = "select * from {$sViewName} where {$sViewName}.oxid= {$sO2AttributeValue}";
$oO2A = oxNew("oxi18n");
$oO2A->setLanguage(oxRegistry::getConfig()->getRequestParameter('editlanguage'));
$oO2A->init("oxobject2attribute");
if ($oO2A->assignRecord($sSelect)) {
$oO2A->oxobject2attribute__oxvalue->setValue($sAttributeValue);
$oO2A->save();
}
}
}
}
}

View File

@ -0,0 +1,37 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright © D³ Data Development, Thomas Dartsch
* @author DÂł Data Development - Daniel Seifert <ds@shopmodule.com>
* @link http://www.oxidmodule.com
*/
class d3_article_attribute_multivalues extends d3_article_attribute_multivalues_parent
{
/**
* Collects article attributes and selection lists, passes them to Smarty engine,
* returns name of template file "article_attribute.tpl".
*
* @return string
*/
public function render()
{
$sTplName = parent::render();
$iAoc = oxRegistry::getConfig()->getRequestParameter("aoc");
if ($iAoc == 1) {
$sTplName = "d3_article_attribute_multivalues.tpl";
}
return $sTplName;
}
}

View File

@ -9,13 +9,11 @@
*
* http://www.shopmodule.com
*
* @copyright <EFBFBD> D<EFBFBD> Data Development, Thomas Dartsch
* @author D<EFBFBD> Data Development - Daniel Seifert <ds@shopmodule.com>
* @copyright © D³ Data Development, Thomas Dartsch
* @author DÂł Data Development - Daniel Seifert <ds@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\AttributeMultiValues\Modules\Application\Model;
class d3_oxattributelist_multivalues extends d3_oxattributelist_multivalues_parent
{
/**

View File

@ -0,0 +1,120 @@
[{include file="popups/headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}]
<script type="text/javascript">
initAoc = function()
{
YAHOO.oxid.container1 = new YAHOO.oxid.aoc( 'container1',
[ [{foreach from=$oxajax.container1 item=aItem key=iKey}]
[{$sSep}][{strip}]{ key:'_[{$iKey}]', ident: [{if $aItem.4}]true[{else}]false[{/if}]
[{if !$aItem.4}],
label: '[{oxmultilang ident="GENERAL_AJAX_SORT_"|cat:$aItem.0|oxupper}]',
visible: [{if $aItem.2}]true[{else}]false[{/if}]
[{/if}]}
[{/strip}]
[{assign var="sSep" value=","}]
[{/foreach}] ],
'[{$oViewConf->getAjaxLink()}]cmpid=container1&container=article_attribute&synchoxid=[{$oxid}]'
);
[{assign var="sSep" value=""}]
YAHOO.oxid.container2 = new YAHOO.oxid.aoc( 'container2',
[ [{foreach from=$oxajax.container2 item=aItem key=iKey}]
[{$sSep}][{strip}]{ key:'_[{$iKey}]', ident: [{if $aItem.4}]true[{else}]false[{/if}]
[{if !$aItem.4}],
label: '[{oxmultilang ident="GENERAL_AJAX_SORT_"|cat:$aItem.0|oxupper}]',
visible: [{if $aItem.2}]true[{else}]false[{/if}],
formatter: YAHOO.oxid.aoc.custFormatter
[{/if}]}
[{/strip}]
[{assign var="sSep" value=","}]
[{/foreach}] ],
'[{$oViewConf->getAjaxLink()}]cmpid=container2&container=article_attribute&oxid=[{$oxid}]'
)
YAHOO.oxid.container1.getDropAction = function()
{
return 'fnc=addattr';
}
YAHOO.oxid.container2.getDropAction = function()
{
return 'fnc=removeattr';
}
YAHOO.oxid.container2.subscribe( "rowClickEvent", function( oParam )
{
var aSelRows= YAHOO.oxid.container2.getSelectedRows();
if ( aSelRows.length ) {
oParam = YAHOO.oxid.container2.getRecord(aSelRows[0]);
$('_attrname').innerHTML = oParam._oData._0;
$('attr_value').value = oParam._oData._2;
$('attr_oxid').value = oParam._oData._3;
$('o2attr_oxid').value = oParam._oData._1; [{*** d3 completed ***}]
$D.setStyle( $('arrt_conf'), 'visibility', '' );
} else {
$D.setStyle( $('arrt_conf'), 'visibility', 'hidden' );
}
})
YAHOO.oxid.container2.subscribe( "dataReturnEvent", function()
{
$D.setStyle( $('arrt_conf'), 'visibility', 'hidden' );
})
YAHOO.oxid.container2.onSave = function()
{
YAHOO.oxid.container1.getDataSource().flushCache();
YAHOO.oxid.container1.getPage( 0 );
YAHOO.oxid.container2.getDataSource().flushCache();
YAHOO.oxid.container2.getPage( 0 );
}
YAHOO.oxid.container2.onFailure = function() { /* currently does nothing */ }
YAHOO.oxid.container2.saveAttribute = function()
{
var callback = {
success: YAHOO.oxid.container2.onSave,
failure: YAHOO.oxid.container2.onFailure,
scope: YAHOO.oxid.container2
};
YAHOO.util.Connect.asyncRequest( 'GET', '[{$oViewConf->getAjaxLink()}]&cmpid=container2&container=article_attribute&fnc=saveAttributeValue&oxid=[{$oxid}]&attr_value=' + encodeURIComponent( $('attr_value').value ) + '&attr_oxid=' + encodeURIComponent( $('attr_oxid').value ) + '&o2attr_oxid=' + encodeURIComponent( $('o2attr_oxid').value ), callback ); [{*** d3 completed***}]
}
// subscribint event listeners on buttons
$E.addListener( $('saveBtn'), "click", YAHOO.oxid.container2.saveAttribute, $('saveBtn') );
}
$E.onDOMReady( initAoc );
</script>
<table width="100%">
<colgroup>
<col span="2" width="40%" />
<col width="20%" />
</colgroup>
<tr class="edittext">
<td colspan="3">[{oxmultilang ident="GENERAL_AJAX_DESCRIPTION"}]<br>[{oxmultilang ident="GENERAL_FILTERING"}]<br /><br /></td>
</tr>
<tr class="edittext">
<td align="center" valign="top"><b>[{oxmultilang ident="ARTICLE_ATTRIBUTE_NOATTRIBUTE"}]</b></td>
<td align="center" valign="top"><b>[{oxmultilang ident="ARTICLE_ATTRIBUTE_ITEMSATTRIBUTE"}]</b></td>
<td align="center" valign="top">[{oxmultilang ident="ARTICLE_ATTRIBUTE_SELECTONEATTR"}]</td>
</tr>
<tr>
<td valign="top" id="container1"></td>
<td valign="top" id="container2"></td>
<td valign="top" align="center" class="edittext" id="arrt_conf" style="visibility:hidden">
<br><br>
<b id="_attrname">[{$attr_name}]</b>:<br><br>
<input id="o2attr_oxid" type="hidden"> [{*** d3 completed ***}]
<input id="attr_oxid" type="hidden">
<input id="attr_value" class="editinput" type="text"><br><br>
<input id="saveBtn" type="button" class="edittext" value="[{oxmultilang ident="ARTICLE_ATTRIBUTE_SAVE"}]">
</td>
</tr>
<tr>
<td class="oxid-aoc-actions"><input type="button" value="[{oxmultilang ident="GENERAL_AJAX_ASSIGNALL"}]" id="container1_btn"></td>
<td class="oxid-aoc-actions"><input type="button" value="[{oxmultilang ident="GENERAL_AJAX_UNASSIGNALL"}]" id="container2_btn"></td>
<td></td>
</tr>
</table>
</body>
</html>

View File

@ -1,36 +0,0 @@
From: Daniel Seifert <ds@shopmodule.com>
Date: Tue, 25 Feb 2020 09:11:32 +0100
---
.../Application/views/admin/tpl/popups/article_attribute.tpl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source/Application/views/admin/tpl/popups/article_attribute.tpl b/source/Application/views/admin/tpl/popups/article_attribute.tpl
index 30633272d..4563c3649 100644
--- a/source/Application/views/admin/tpl/popups/article_attribute.tpl
+++ b/source/Application/views/admin/tpl/popups/article_attribute.tpl
@@ -49,6 +49,7 @@
$('_attrname').innerHTML = oParam._oData._0;
$('attr_value').value = oParam._oData._2;
$('attr_oxid').value = oParam._oData._3;
+ $('o2attr_oxid').value = oParam._oData._1; [{*** d3 completed ***}]
$D.setStyle( $('arrt_conf'), 'visibility', '' );
} else {
$D.setStyle( $('arrt_conf'), 'visibility', 'hidden' );
@@ -73,7 +74,7 @@
failure: YAHOO.oxid.container2.onFailure,
scope: YAHOO.oxid.container2
};
- YAHOO.util.Connect.asyncRequest( 'GET', '[{$oViewConf->getAjaxLink()}]&cmpid=container2&container=article_attribute&fnc=saveAttributeValue&oxid=[{$oxid}]&attr_value=' + encodeURIComponent( $('attr_value').value ) + '&attr_oxid=' + encodeURIComponent( $('attr_oxid').value ), callback );
+ YAHOO.util.Connect.asyncRequest( 'GET', '[{$oViewConf->getAjaxLink()}]&cmpid=container2&container=article_attribute&fnc=saveAttributeValue&oxid=[{$oxid}]&attr_value=' + encodeURIComponent( $('attr_value').value ) + '&attr_oxid=' + encodeURIComponent( $('attr_oxid').value ) + '&o2attr_oxid=' + encodeURIComponent( $('o2attr_oxid').value ), callback ); [{*** d3 completed***}]
}
// subscribint event listeners on buttons
@@ -101,6 +102,7 @@
<td valign="top" align="center" class="edittext" id="arrt_conf" style="visibility:hidden">
<br><br>
<b id="_attrname">[{$attr_name}]</b>:<br><br>
+ <input id="o2attr_oxid" type="hidden"> [{*** d3 completed ***}]
<input id="attr_oxid" type="hidden">
<input id="attr_value" class="editinput" type="text"><br><br>
<input id="saveBtn" type="button" class="edittext" value="[{oxmultilang ident="ARTICLE_ATTRIBUTE_SAVE"}]">

8
setup+doku/usage.txt Normal file
View File

@ -0,0 +1,8 @@
entwickelt in EE 5.2.1
ermöglicht, im Admin ein Attribute einem Artikel mehrfach mit unterschiedlichen Werten zuzuordnen
Artikel A
-> Farbe "rot"
-> Farbe "grĂĽn"
-> Material "Stoff"

View File

@ -1,30 +0,0 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright <EFBFBD> D<EFBFBD> Data Development, Thomas Dartsch
* @author D<EFBFBD> Data Development - Daniel Seifert <ds@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\AttributeMultiValues\Modules\Application\Controllers\Admin {
use OxidEsales\Eshop\Application\Controller\Admin\ArticleAttributeAjax;
class d3_article_attribute_ajax_multivalues_parent extends ArticleAttributeAjax {}
}
namespace D3\AttributeMultiValues\Modules\Application\Model {
use OxidEsales\Eshop\Application\Model\AttributeList;
class d3_oxattributelist_multivalues_parent extends AttributeList {}
}

View File

@ -1,91 +0,0 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright <EFBFBD> D<EFBFBD> Data Development, Thomas Dartsch
* @author D<EFBFBD> Data Development - Daniel Seifert <ds@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\AttributeMultiValues\Modules\Application\Controllers\Admin;
use Exception;
use OxidEsales\Eshop\Application\Model\Article;
use OxidEsales\Eshop\Application\Model\Attribute;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Model\MultiLanguageModel;
use OxidEsales\Eshop\Core\Registry;
class d3_article_attribute_ajax_multivalues extends d3_article_attribute_ajax_multivalues_parent
{
/**
* Returns SQL query for data to fetc
*
* @return string
*/
protected function _getQuery()
{
$sQAdd = parent::_getQuery();
$sArtId = Registry::getRequest()->getRequestParameter('oxid');
if (false == $sArtId) {
/** @var Attribute $attribute */
$attribute = oxNew(Attribute::class);
$sAttrViewName = $attribute->getViewName();
$sQAdd = " from {$sAttrViewName} where {$sAttrViewName}.oxid ";
}
return $sQAdd;
}
/**
* Saves attribute value
*
* @return void|null
* @throws DatabaseConnectionException
* @throws Exception
*/
public function saveAttributeValue()
{
$database = DatabaseProvider::getDb();
$request = Registry::getRequest();
$this->resetContentCache();
$articleId = $request->getRequestParameter("oxid");
$attributeId = $request->getRequestParameter("attr_oxid");
$attributeValue = $request->getRequestParameter("attr_value");
$article = oxNew(Article::class);
if ($article->load($articleId)) {
if ($article->isDerived()) {
return;
}
$this->onAttributeValueChange($article);
if (isset($attributeId) && ("" != $attributeId)) {
$viewName = $this->_getViewName("oxobject2attribute");
$quotedArticleId = $database->quote($article->getId());
// D3: remove unused attrid selection
$select = "select * from {$viewName} where {$viewName}.oxobjectid= {$quotedArticleId}";
$objectToAttribute = oxNew(MultiLanguageModel::class);
$objectToAttribute->setLanguage($request->getRequestParameter('editlanguage'));
$objectToAttribute->init("oxobject2attribute");
if ($objectToAttribute->assignRecord($select)) {
$objectToAttribute->oxobject2attribute__oxvalue->setValue($attributeValue);
$objectToAttribute->save();
}
}
}
}
}

View File

@ -1,40 +0,0 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
use D3\AttributeMultiValues\Modules\Application\Controllers\Admin\d3_article_attribute_ajax_multivalues;
use D3\AttributeMultiValues\Modules\Application\Model\d3_oxattributelist_multivalues;
use OxidEsales\Eshop\Application\Controller\Admin\ArticleAttributeAjax;
use OxidEsales\Eshop\Application\Model\AttributeList;
/**
* Metadata version
*/
$sMetadataVersion = '2.1';
/**
* Module information
*/
$aModule = array(
'id' => 'd3attributemultivalues',
'title' => 'D&sup3; mehrfache Wertezuordnung zu Attributen',
'version' => '0.0.0.1',
'author' => 'D&sup3; Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com',
'url' => 'http://www.oxidmodule.com/',
'extend' => [
ArticleAttributeAjax::class => d3_article_attribute_ajax_multivalues::class,
AttributeList::class => d3_oxattributelist_multivalues::class,
]
);