Skip to content

Commit

Permalink
ADD: Supplier ref in Products Lists
Browse files Browse the repository at this point in the history
  • Loading branch information
BadPixxel committed Oct 22, 2020
1 parent 6f8a611 commit c49f1a9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion modules/splashsync/src/Objects/Product/MainTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ protected function buildMainFields()
->Identifier("supplier_reference")
->Name(Translate::getAdminTranslation("Supplier reference", "AdminProducts"))
->addOption("shop", MSM::MODE_ALL)
->MicroData("http://schema.org/Product", "mpn");
->MicroData("http://schema.org/Product", "mpn")
->isListed()
;
//====================================================================//
// UPC
$this->fieldsFactory()->create(SPL_T_INT)
Expand Down
9 changes: 8 additions & 1 deletion modules/splashsync/src/Objects/Product/ObjectsListTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function objectsList($filter = null, $params = null)
$sql->select("pa.`id_product_attribute` as id_attribute");
$sql->select("p.`reference` as ref");
$sql->select("pa.`reference` as ref_attribute");
$sql->select("p.`supplier_reference` as supplier_reference");
$sql->select("pa.`supplier_reference` as supplier_reference_attribute");
$sql->select("pl.`name` as name");
$sql->select("p.`quantity` as stock");
$sql->select("p.`weight` as weight");
Expand Down Expand Up @@ -111,7 +113,7 @@ private static function getFilters($filter = null)

//====================================================================//
// Setup String Filters
// Add filters with names convertions. Added LOWER function to be NON case sensitive
// Add filters with names conversions. Added LOWER function to be NON case sensitive
if (!empty($filter)) {
//====================================================================//
// Search by Product Name
Expand All @@ -123,6 +125,9 @@ private static function getFilters($filter = null)
// Search by Product Ref
$stringFilters .= " OR LOWER( p.reference ) LIKE LOWER( '%".pSQL($filter)."%') ";
//====================================================================//
// Search by Product Supplier Ref
$stringFilters .= " OR LOWER( p.supplier_reference ) LIKE LOWER( '%".pSQL($filter)."%') ";
//====================================================================//
// Search by Product Variant Ref
$stringFilters .= " OR LOWER( pa.reference ) LIKE LOWER( '%".pSQL($filter)."%') ";
//====================================================================//
Expand Down Expand Up @@ -186,6 +191,7 @@ private function getTransformedProductArray($product)
if (!$product["id_attribute"]) {
$dataBuffer["id"] = $product["id"];
$dataBuffer["ref"] = $product["ref"];
$dataBuffer["supplier_reference"] = $product["supplier_reference"];
$dataBuffer["weight"] = $product["weight"].Configuration::get('PS_WEIGHT_UNIT');
$dataBuffer["stock"] = $productClass->getQuantity($product["id"]);
$dataBuffer["price"] = $productClass->getPrice(false, null, 3);
Expand All @@ -197,6 +203,7 @@ private function getTransformedProductArray($product)
$dataBuffer["ref"] = (empty($product["ref_attribute"]) && !empty($product["ref"]))
?$product["ref"]."-".$product["id_attribute"]
:$product["ref_attribute"];
$dataBuffer["supplier_reference"] = $product["supplier_reference_attribute"];
$dataBuffer["weight"] = ($product["weight"] + $product["weight_attribute"]);
$dataBuffer["weight"] .= Configuration::get('PS_WEIGHT_UNIT');
$dataBuffer["price"] = $productClass->getPrice(false, $product["id_attribute"], 3);
Expand Down
13 changes: 7 additions & 6 deletions modules/splashsync/src/Objects/Product/PricesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ trait PricesTrait
*
* @return void
*/
private function buildPricesFields()
protected function buildPricesFields()
{
//====================================================================//
// PRICES INFORMATIONS
Expand All @@ -56,7 +56,8 @@ private function buildPricesFields()
)." (".$this->Currency->sign.")"
)
->MicroData("http://schema.org/Product", "price")
->isListed();
->isListed()
;

//====================================================================//
// Product Selling Base Price
Expand All @@ -69,7 +70,7 @@ private function buildPricesFields()
)." Base (".$this->Currency->sign.")"
)
->MicroData("http://schema.org/Product", "basePrice")
->isListed();
;

//====================================================================//
// WholeSale Price
Expand Down Expand Up @@ -106,7 +107,7 @@ private function buildPricesFields()
*
* @return void
*/
private function getPricesFields($key, $fieldName)
protected function getPricesFields($key, $fieldName)
{
//====================================================================//
// READ Fields
Expand Down Expand Up @@ -190,7 +191,7 @@ private function getPricesFields($key, $fieldName)
*
* @return void
*/
private function getReducedPricesFields($key, $fieldName)
protected function getReducedPricesFields($key, $fieldName)
{
//====================================================================//
// READ Fields
Expand Down Expand Up @@ -232,7 +233,7 @@ private function getReducedPricesFields($key, $fieldName)
*
* @return void
*/
private function setPricesFields($fieldName, $fieldData)
protected function setPricesFields($fieldName, $fieldData)
{
//====================================================================//
// WRITE Field
Expand Down

0 comments on commit c49f1a9

Please sign in to comment.