Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Jul 10, 2023
2 parents 5711907 + d8bd81b commit 68900aa
Show file tree
Hide file tree
Showing 168 changed files with 89,246 additions and 89,179 deletions.
45 changes: 45 additions & 0 deletions .ddev/commands/web/openmage-admin
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

## ProjectTypes: magento
## Description: Create/Update OpenMage Administrator Account
## Usage: openmage-admin
## Example: ddev openmage-admin

read -r -p "Choose your action for the administrator account [Create/Update]: " ACTION
ACTION=${ACTION,,} # to lower

if [[ "${ACTION}" =~ ^(update|u) || "${ACTION}" =~ ^(create|c) ]]; then
read -r -p "Admin User [admin]: " ADMIN_USER
ADMIN_USER=${ADMIN_USER:-admin}
read -r -p "Admin Firstname [OpenMage]: " ADMIN_FIRSTNAME
ADMIN_FIRSTNAME=${ADMIN_FIRSTNAME:-OpenMage}
read -r -p "Admin Lastname [Administrator]: " ADMIN_LASTNAME
ADMIN_LASTNAME=${ADMIN_LASTNAME:-Administrator}
read -r -p "Admin Email [admin@example.com]: " ADMIN_EMAIL
ADMIN_EMAIL=${ADMIN_EMAIL:-admin@example.com}
read -r -p "Admin Password [veryl0ngpassw0rd]: " ADMIN_PASSWORD
ADMIN_PASSWORD=${ADMIN_PASSWORD:-veryl0ngpassw0rd}
read -r -p "Table Prefix []: " TABLE_PREFIX
TABLE_PREFIX=${TABLE_PREFIX:-}
else
echo "Please run again and choose an action."
exit 1
fi

RANDOM_STRING=$({ tr -dc A-Za-z0-9 </dev/urandom | head -c 32 ; })

if [[ "${ACTION}" =~ ^(update|u) ]]; then
if mysql -u db -h db db -e "UPDATE "${TABLE_PREFIX}"admin_user SET password=CONCAT(MD5('"${RANDOM_STRING}""${ADMIN_PASSWORD}"'),':"${RANDOM_STRING}"') WHERE username='"${ADMIN_USER}"'"; then
echo "If the account "${ADMIN_USER}" exists it has been updated."
else
exit 1
fi
elif [[ "${ACTION}" =~ ^(create|c) ]]; then
if mysql -u db -h db db -e "INSERT INTO "${TABLE_PREFIX}"admin_user (firstname, lastname, email, username, password) VALUES ('"${ADMIN_FIRSTNAME}"', '"${ADMIN_LASTNAME}"', '"${ADMIN_EMAIL}"', '"${ADMIN_USER}"', CONCAT(MD5('"${RANDOM_STRING}""${ADMIN_PASSWORD}"'), ':"${RANDOM_STRING}"'))"; then
mysql -u db -h db db -e "INSERT INTO "${TABLE_PREFIX}"admin_role(parent_id, tree_level, sort_order, role_type, user_id, role_name)
VALUES (1, 2, 0, 'U',(SELECT user_id FROM "${TABLE_PREFIX}"admin_user WHERE username = '"${ADMIN_USER}"'),'"${ADMIN_FIRSTNAME}"')"
echo "The account "$ADMIN_USER" has been created."
else
exit 1
fi
fi
2 changes: 1 addition & 1 deletion .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch \.(dist|lock|md|neon|sample|sh|yml|yaml)$>
<FilesMatch \.(dist|flag|ip|lock|md|neon|sample|sh|yml|yaml)$>
Order allow,deny
Deny from all
</FilesMatch>
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Catalog/Helper/Product/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ public function prepareAndRender($productId, $controller, $params = null)
throw new Mage_Core_Exception($this->__('Product is not loaded'), $this->ERR_NO_PRODUCT_LOADED);
}

$buyRequest = $params->getBuyRequest();
/** @see Mage_Checkout_CartController::_setProductBuyRequest() */
$checkoutBuyRequest = Mage::getSingleton('checkout/session')->getProductBuyRequest(true);
$buyRequest = $params->getBuyRequest() ?: $checkoutBuyRequest;
if ($buyRequest) {
$productHelper->prepareProductOptions($product, $buyRequest);
}
Expand Down
18 changes: 17 additions & 1 deletion app/code/core/Mage/Checkout/controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,19 @@ public function addAction()
} else {
$messages = array_unique(explode("\n", $e->getMessage()));
foreach ($messages as $message) {
$this->_getSession()->addError(Mage::helper('core')->escapeHtml($message));
$this->_getSession()->addError(Mage::helper('core')->escapeHtml($message, ['em']));
}
}

$url = $this->_getSession()->getRedirectUrl(true);
if ($url) {
$this->_setProductBuyRequest();
$this->getResponse()->setRedirect($url);
} else {
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
}
} catch (Exception $e) {
$this->_setProductBuyRequest();
$this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
$this->_goBack();
}
Expand Down Expand Up @@ -415,6 +417,7 @@ public function updateItemOptionsAction()
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
}
} catch (Exception $e) {
$this->_setProductBuyRequest();
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
$this->_goBack();
}
Expand Down Expand Up @@ -711,4 +714,17 @@ protected function _getCustomerSession()
{
return Mage::getSingleton('customer/session');
}

/**
* Set product form data in checkout session for populating the product form
* in case of errors in add to cart process.
*
* @return void
*/
protected function _setProductBuyRequest(): void
{
$buyRequest = $this->getRequest()->getPost();
$buyRequestObject = new Varien_Object($buyRequest);
$this->_getSession()->setProductBuyRequest($buyRequestObject);
}
}
35 changes: 18 additions & 17 deletions app/code/core/Mage/GoogleAnalytics/Block/Ga.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
$_removedProduct = Mage::getModel('catalog/product')->load($removedProduct);
$eventData = [];
$eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
$eventData['value'] = number_format($_removedProduct->getFinalPrice(), 2);
$eventData['value'] = number_format($_removedProduct->getFinalPrice(), 2, '.', '');
$eventData['items'] = [];
$_item = [
'item_id' => $_removedProduct->getSku(),
'item_name' => $_removedProduct->getName(),
'price' => number_format($_removedProduct->getFinalPrice(), 2),
'price' => number_format($_removedProduct->getFinalPrice(), 2, '.', ''),
];
if ($_removedProduct->getAttributeText('manufacturer')) {
$_item['item_brand'] = $_removedProduct->getAttributeText('manufacturer');
Expand All @@ -174,12 +174,12 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
$_addedProduct = Mage::getModel('catalog/product')->load($addedProduct);
$eventData = [];
$eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
$eventData['value'] = number_format($_addedProduct->getFinalPrice(), 2);
$eventData['value'] = number_format($_addedProduct->getFinalPrice(), 2, '.', '');
$eventData['items'] = [];
$_item = [
'item_id' => $_addedProduct->getSku(),
'item_name' => $_addedProduct->getName(),
'price' => number_format($_addedProduct->getFinalPrice(), 2),
'price' => number_format($_addedProduct->getFinalPrice(), 2, '.', ''),
];
if ($_addedProduct->getAttributeText('manufacturer')) {
$_item['item_brand'] = $_addedProduct->getAttributeText('manufacturer');
Expand All @@ -205,14 +205,14 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
$category = Mage::registry('current_category') ? Mage::registry('current_category')->getName() : false;
$eventData = [];
$eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
$eventData['value'] = number_format($productViewed->getFinalPrice(), 2);
$eventData['value'] = number_format($productViewed->getFinalPrice(), 2, '.', '');
$eventData['items'] = [];
$_item = [
'item_id' => $productViewed->getSku(),
'item_name' => $productViewed->getName(),
'list_name' => 'Product Detail Page',
'item_category' => $category,
'price' => number_format($productViewed->getFinalPrice(), 2),
'price' => number_format($productViewed->getFinalPrice(), 2, '.', ''),
];
if ($productViewed->getAttributeText('manufacturer')) {
$_item['item_brand'] = $productViewed->getAttributeText('manufacturer');
Expand Down Expand Up @@ -251,7 +251,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
'item_id' => $productViewed->getSku(),
'index' => $index,
'item_name' => $productViewed->getName(),
'price' => number_format($productViewed->getFinalPrice(), 2),
'price' => number_format($productViewed->getFinalPrice(), 2, '.', ''),
];
if ($productViewed->getAttributeText('manufacturer')) {
$_item['item_brand'] = $productViewed->getAttributeText('manufacturer');
Expand All @@ -263,7 +263,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
$index++;
$eventData['value'] += $productViewed->getFinalPrice();
}
$eventData['value'] = number_format($eventData['value'], 2);
$eventData['value'] = number_format($eventData['value'], 2, '.', '');
$result[] = "gtag('event', 'view_item_list', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
}

Expand All @@ -284,7 +284,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
$_item = [
'item_id' => $_product->getSku(),
'item_name' => $_product->getName(),
'price' => number_format($_product->getFinalPrice(), 2),
'price' => number_format($_product->getFinalPrice(), 2, '.', ''),
'quantity' => (int) $productInCart->getQty(),
];
if ($_product->getAttributeText('manufacturer')) {
Expand All @@ -298,7 +298,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
array_push($eventData['items'], $_item);
$eventData['value'] += $_product->getFinalPrice();
}
$eventData['value'] = number_format($eventData['value'], 2);
$eventData['value'] = number_format($eventData['value'], 2, '.', '');
$result[] = "gtag('event', 'view_cart', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
}

Expand All @@ -319,7 +319,8 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
$_item = [
'item_id' => $_product->getSku(),
'item_name' => $_product->getName(),
'price' => number_format($_product->getFinalPrice(), 2),
'price' => number_format($_product->getFinalPrice(), 2, '.', ''),
'quantity' => (int) $productInCart->getQty(),
];
if ($_product->getAttributeText('manufacturer')) {
$_item['item_brand'] = $_product->getAttributeText('manufacturer');
Expand All @@ -332,7 +333,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
array_push($eventData['items'], $_item);
$eventData['value'] += $_product->getFinalPrice();
}
$eventData['value'] = number_format($eventData['value'], 2);
$eventData['value'] = number_format($eventData['value'], 2, '.', '');
$result[] = "gtag('event', 'begin_checkout', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
}
}
Expand All @@ -351,10 +352,10 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
$orderData = [
'currency' => $order->getBaseCurrencyCode(),
'transaction_id' => $order->getIncrementId(),
'value' => number_format($order->getBaseGrandTotal(), 2),
'value' => number_format($order->getBaseGrandTotal(), 2, '.', ''),
'coupon' => strtoupper($order->getCouponCode()),
'shipping' => number_format($order->getBaseShippingAmount(), 2),
'tax' => number_format($order->getBaseTaxAmount(), 2),
'shipping' => number_format($order->getBaseShippingAmount(), 2, '.', ''),
'tax' => number_format($order->getBaseTaxAmount(), 2, '.', ''),
'items' => []
];

Expand All @@ -364,8 +365,8 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
'item_id' => $item->getSku(),
'item_name' => $item->getName(),
'quantity' => (int) $item->getQtyOrdered(),
'price' => number_format($item->getBasePrice(), 2),
'discount' => number_format($item->getBaseDiscountAmount(), 2)
'price' => number_format($item->getBasePrice(), 2, '.', ''),
'discount' => number_format($item->getBaseDiscountAmount(), 2, '.', '')
];
$_product = Mage::getModel('catalog/product')->load($item->getProductId());
if ($_product->getAttributeText('manufacturer')) {
Expand Down
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
}
},
"extra": {
"branch-alias": {
"dev-main": "1.9.4.x-dev"
},
"magento-root-dir": ".",
"magento-deploystrategy": "copy",
"magento-deploystrategy-dev": "symlink",
Expand Down
Loading

0 comments on commit 68900aa

Please sign in to comment.