Skip to content

Commit

Permalink
- [#230] Fixed the inability to change vendor of a product more than …
Browse files Browse the repository at this point in the history
…1 times
  • Loading branch information
bezumkin committed Sep 14, 2016
1 parent eb0037e commit b8df201
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
1 change: 0 additions & 1 deletion assets/components/minishop2/js/mgr/misc/ms2.combo.js
Expand Up @@ -199,7 +199,6 @@ miniShop2.combo.Vendor = function (config) {
action: 'mgr/settings/vendor/getlist',
combo: true,
id: config.value,
//limit: 0,
}
});
miniShop2.combo.Vendor.superclass.constructor.call(this, config);
Expand Down
1 change: 1 addition & 0 deletions core/components/minishop2/docs/changelog.txt
Expand Up @@ -5,6 +5,7 @@ Changelog for miniShop2.
- [#237] Fixed msProductData::get('options') method.
- [#236] Ability to display category columns of an ordered product.
- [#231] Snippet msOptions now transfers id of a product into a chunk.
- [#230] Fixed the inability to change vendor of a product more than 1 times.
- [#228] Possible fix for "empty file" in product gallery on some server configurations.
- [#227] Improved performance of the grid with options in settings.

Expand Down
Expand Up @@ -13,7 +13,7 @@ class msCategoryGetCatsProcessor extends modObjectGetListProcessor
*/
public function initialize()
{
if ($this->getProperty('combo') && !$this->getProperty('limit') && $id = $this->getProperty('id')) {
if ($this->getProperty('combo') && !$this->getProperty('limit') && $id = (int)$this->getProperty('id')) {
$this->item_id = $id;
}
$this->setDefaultProperties(array(
Expand Down Expand Up @@ -115,12 +115,10 @@ public function prepareQueryBeforeCount(xPDOQuery $c)
'class_key' => 'msCategory',
));

if ($query = $this->getProperty('query')) {
if ($this->item_id) {
$c->where(array('id' => $this->item_id));
} elseif ($query = $this->getProperty('query')) {
$c->where(array('pagetitle:LIKE' => "%$query%"));
} else {
if ($this->item_id) {
$c->where(array('id' => $this->item_id));
}
}

return $c;
Expand Down
Expand Up @@ -7,13 +7,17 @@ class msProductGetListProcessor extends modObjectGetListProcessor
public $defaultSortField = 'menuindex';
public $defaultSortDirection = 'ASC';
public $parent = 0;
protected $item_id = 0;


/**
* @return bool
*/
public function initialize()
{
if ($this->getProperty('combo') && !$this->getProperty('limit') && $id = (int)$this->getProperty('id')) {
$this->item_id = $id;
}
if (!$this->getProperty('limit')) {
$this->setProperty('limit', 20);
}
Expand Down Expand Up @@ -45,8 +49,8 @@ public function prepareQueryBeforeCount(xPDOQuery $c)
$c->select($this->modx->getSelectColumns('msVendor', 'Vendor', 'vendor_', array('name')));
$c->select($this->modx->getSelectColumns('msCategory', 'Category', 'category_', array('pagetitle')));
}
if ($id = (int)$this->getProperty('id')) {
$c->where(array('msProduct.id' => $id));
if ($this->item_id) {
$c->where(array('msProduct.id' => $this->item_id));
if ($parent = (int)$this->getProperty('parent')) {
$this->parent = $parent;
}
Expand Down
Expand Up @@ -6,13 +6,17 @@ class msVendorGetListProcessor extends modObjectGetListProcessor
public $defaultSortField = 'id';
public $defaultSortDirection = 'ASC';
public $permission = 'mssetting_list';
protected $item_id = 0;


/**
* @return bool|null|string
*/
public function initialize()
{
if ($this->getProperty('combo') && !$this->getProperty('limit') && $id = (int)$this->getProperty('id')) {
$this->item_id = $id;
}
if (!$this->modx->hasPermission($this->permission)) {
return $this->modx->lexicon('access_denied');
}
Expand All @@ -30,16 +34,14 @@ public function prepareQueryBeforeCount(xPDOQuery $c)
{
if ($this->getProperty('combo')) {
$c->select('id,name');
}
else {
} else {
$c->leftJoin('modResource', 'Resource');
$c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
$c->select('Resource.pagetitle');
}
if ($id = (int)$this->getProperty('id')) {
$c->where(array('id' => $id));
}
if ($query = trim($this->getProperty('query'))) {
if ($this->item_id) {
$c->where(array('id' => $this->item_id));
} elseif ($query = trim($this->getProperty('query'))) {
$c->where(array(
'name:LIKE' => "%{$query}%",
'OR:description:LIKE' => "%{$query}%",
Expand Down

0 comments on commit b8df201

Please sign in to comment.