#StackBounty: #magento-1.9 #url-rewrite Magento v1.9.x ultimate module creator entity URL rewrite / key problem

Bounty: 50

Hi all ( especially Marius 🙂 )

I have an annoying problem with my Mag 1.9.x modules created using the, otherwise great, ultimate module creator. When an item/entity is given a friendly URL and initially saved then all is great. However, if the item/entity is reloaded, edited in some way and saved then the friendly URL (unchanged) is seen as a duplicate of the existing URL and then appends -1, -2, -3….and so on for each save. This then means the proper/original URL no longer works and the URL changes with each edit. It is possible to go back and then remove the -1 (or whatever number it has reached) as the original no longer exists as a URL.

It seems that this might not be specific to UMC modules but any entity types that are not products, categories or otherwise inbuilt to Magento. I wondered if there was a known fix for this as I am already fiddling with overwriting the core to check if the found matching url actually belongs to the same item as you are currently saving so not to update it but it is proving troublesome and seems to impact quite a lot of things.

Thanks
Jon


Get this bounty!!!

#StackBounty: #magento-1.9 #shipping-methods #create-order Get the available (and Working) Shipping Methods for a quote

Bounty: 50

I’m working on a mobile application, that is creating an order on Magento programmatically through a custom REST implementation, and everything is working fine, except one thing that i can’t find any documentation on: How to set the shipping method for the quote that complies with the available shipping method rules.

So for example, from the Magento backend there are 3 shipping methods enabled:

  1. Free – Only when cart amount is above 80 USD
  2. Fixed Rate – Only if Customer is ordering from USA
  3. Tablerate – If the customer is ordering from outside the USA.

What I was doing was as follows (assuming $quote has the quote built up and the products added to it):

$shippingAddress = $quote->getShippingAddress()->addData($shipping_address);    

$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
foreach($methods as $_code => $_method){
    // Get the first allowed method of this shipping carrier
    $m = key($_method->getAllowedMethods()); 
    $shipping_method = $_code . '_' . $m;
    break;
}

$quote->collectTotals();
$shippingAddress->setWeight( $weights )
                ->setFreeMethodWeight( $weights )
                ->setShippingMethod( $shipping_method );

Which is kinda retarded, I’m simply getting all ActiveCarriers, and assigning the first one to the quote, which can work in simple scenarios. However, in this example, the first Active Carrier won’t work, because i’m not validating the country rules or free shipping rules. So my question is, how can I get the best (and valid) shipping methods for this quote. Is there any built-in function or helper method that I can use?

I’m assuming that I don’t want to give the option to the customer to select the shipping method. I want to just assign the complying shipping method to the quote.


Get this bounty!!!

#StackBounty: #magento-1.9 #order-status #stock-status #order-state Magento statuses and states and reviews through kount/braintree (GE…

Bounty: 50

I’m working on changing various “order states” based on their statuses in magento when they come in via kount Ens.php. I’ve had some success with a couple of them but I can’t seem to figure out the last three.

  1. When approved manually the state code needs to change to processing
    instead of payment_review.
  2. When declined maually the state code needs to change to holded
    instead of payment_review.
  3. When auto declined the state code needs to changed to canceled
    instead of payment_review.

Here’s what I have currently:

/**
 * Approve an order from Kount
 *
 * @param Mage_Sales_Model_Order $order
 *
 * @return bool
 */
protected function _approveOrder(Mage_Sales_Model_Order $order)
{
    // Ensure the status has not moved from it's payment review state
    if ($order->getStatus() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {

        // Inform the system that this update is occurring from an ENS update
        Mage::register('kount_ens_update', true);

        try {
            $order->setStatus("fraud_cleared");
            $order->save();
        } catch (Exception $e) {
            Gene_Braintree_Model_Debug::log('Accept Kount transaction failed to be accepted in Magento: ' . $e->getMessage());
            Gene_Braintree_Model_Debug::log($e);
            return false;
        }

        Mage::unregister('kount_ens_update');
        $order->addStatusHistoryComment('Order approved through Kount.')->save();
        return true;
    }

    return false;
}

/**
 * Decline an order in Magento
 *
 * If the payment is only voidable, we void the invoice cancelling the order. If the payment has settled we create
 * a credit memo and close the order that way.
 *
 * @param Mage_Sales_Model_Order $order
 *
 * @return bool
 */
protected function _declineOrder(Mage_Sales_Model_Order $order)
{
    // Ensure the status has not moved from it's payment review state
    if ($order->getStatus() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {

        // Inform the system that this update is occurring from an ENS update
        Mage::register('kount_ens_update', true);
        try {
            $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, "suspected_fraud_after_review");
            $order->save();
        } catch (Exception $e) {
            Gene_Braintree_Model_Debug::log('Declined Kount transaction failed to be declined in Magento: ' . $e->getMessage());
            Gene_Braintree_Model_Debug::log($e);
            return false;
        }

    }

    return false;
}

Here’s some things i’m working on to fix:

try {
                $order->setStatus("fraud_cleared")
                    ->setState(Mage_Sales_Model_Order::STATE_PROCESSING)
                    ->save();
            } catch (Exception $e) {
                Gene_Braintree_Model_Debug::log('Accept Kount transaction failed to be accepted in Magento: ' . $e->getMessage());
                Gene_Braintree_Model_Debug::log($e);
                return false;
            }

enter image description here


Get this bounty!!!

#StackBounty: #magento-1.9 #ce-1.9.0.1 #customer-session Magento 1.9.0.1 Homepage session

Bounty: 50

I am having problem regarding the customer/session on Magento homepage.
Currently i can access and get all Customer information using customer/session but not in Homepage. In all other pages i can get the customer.
I have also made a clone of project on local machine (Ubuntu 16.04) which is identical as the online server. In local server i can get the correct Customer from session.

When i try to get the customer from session on Mage_Core_Controller_Varien_Action i get the correct Customer.

in Mage_Cms_IndexController in indexAction Method i get empty customer.

Any help is appreciated.


Get this bounty!!!

#StackBounty: #magento-1.9 #module #adminhtml #extensions #global-messages Show custom Admin Messages In configuration section custom m…

Bounty: 50

I created a custom module which fetch data using third-party APIs.

In admin Dashboard after module installation.
I want to check few things form API( i am getting everything from API , just need to show show message once admin activate the module ) if all ok i want to show the message under the Enable/Disable button.

errormesage section

inrsaurabh

If i trying the below method , when i change the configuration values of my custom module. i hit api to validate few things

This works

Mage::getConfig()->saveConfig(‘someotheremodule/debug/logenabled’, ‘0’, ‘default’, 0);
Mage::getConfig()->saveConfig(‘smtpsomeotheremodulepro/debug/log_debug’, ‘1’, ‘default’, 0);

This is not working

Mage::getConfig()->saveConfig(‘reviewrating/section_one/active’, ‘1’, ‘default’, 0);

How to change the config values by my custom module?
Currently i attached <backend_model>reviewrating/Statuswidget</backend_model> to one of the fields is it the only way to get values and in this way i have to use same process for each field?

In
/var/www/html/magento16/app/code/local/Namespace/ReviewRating/etc/config.xml

     <!-- ... -->
            <admin_system_config_changed_section_sectionone>
                <observers>
                    <mymodule>
                        <type>singleton</type>
                        <class>Namespace_ReviewRating_Model_Observer</class>
                        <method>changeSystemConfig</method>
                    </mymodule>
                </observers>
            </admin_system_config_changed_section_sectionone>
        </events>
  </global>
        <!-- ... -->

In /var/www/html/namespace/app/code/local/Namespace/ReviewRating/Model/Statuswidget.php

<?php
/**
 *  
 * @author      inrsaurabh
 */

class Namespace_ReviewRating_Model_Statuswidget extends Mage_Core_Model_Config_Data
{

     protected function _beforeSave()
{
    $value = $this->getValue();
    Mage::log( $value );

    // if widget activated ( enable = 1 ) 


    $apidDataCheck = Mage::helper('reviewrating')->checkWidgetStatus( $value );
    $isError = $apidDataCheck['success'];
    Mage::log( $isError );

    if( $isError != 1 ){
        Mage::log('Disable module');

        Mage::getConfig()->saveConfig('reviewrating/section_one/active', '0', 'default', 0);
// above line dont change config value 

        Mage::getSingleton('adminhtml/session')->addWarning( $isError ); 



    } else {
         Mage::getSingleton('adminhtml/session')->addSuccess('Psydro Widget Enabled'); 
    }

}

In /var/www/html/magento16/app/code/local/Namespace/ReviewRating/etc/system.xml

 <sections>
        <reviewrating translate="label" module="reviewrating">
            <!-- -->
              <groups>
                <section_one translate="label">
              <!-- -->
              <active translate="label comment">
                        <label>Widget Status </label>
                        <frontend_type>select</frontend_type>
                        <sort_order>54</sort_order>
                        <source_model>adminhtml/system_config_source_enabledisable</source_model>
                        <backend_model>reviewrating/Statuswidget</backend_model>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
              </active>
              <!-- ... -->
              </section_one>
              <!--- -->
             </groups>
        <!-- -->
      </section>

Please suggest how to proceed. I didn’t find any link related to this in which I can hit API on enable/disable button and then show messages.

Thank You.


Get this bounty!!!