texts: Magento2 - adminhtml_customer not showing in Forms to Use In

texts:
I have programatically created a customer attribute and set it to be displayed in adminhtml_customer. All is good, the attribute is being displayed only in the admin customer edit section as desired.

$attributeCode = 'attribute_code';

$eavSetup->addAttribute(Customer::ENTITY, $attributeCode,
    [
        'type'          => 'varchar',
        'label'         => 'Attribute Lable',
        'input'         => 'multiselect',
        'backend'       => \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class,
        'global'        => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
        'source'        => \Magento\Eav\Model\Entity\Attribute\Source\Table::class,
        'visible'       => true,
        'user_defined'  => true,
        'system'        => false,
        'required'      => false,
        'unique'        => false,
        'position'      => 200
    ]
);

$attribute = $this->eavConfig->getAttribute(Customer::ENTITY, $attributeCode);

$attribute
    ->setData('used_in_forms', ['adminhtml_customer'])
    ->save();

However, when I try to edit the attribute in the M2 admin (Store/Attributes/Customer) - let's say I want to make it show in another area, the adminhtml_customer option is not available for selection in the Forms to Use In list (adminhtml_customer_address is not available either).

Looking through the code I found the following:

\Magento\CustomerCustomAttributes\Helper\Customer::getAttributeFormOptions

/**
 * Return available customer attribute form as select options
 *
 * @return array
 */
public function getAttributeFormOptions()
{
    return [
        ['label' => __('Customer Registration'), 'value' => 'customer_account_create'],
        ['label' => __('Customer Account Edit'), 'value' => 'customer_account_edit'],
        ['label' => __('Admin Checkout'), 'value' => 'adminhtml_checkout']
    ];
}

Since adminhtml_customer and adminhtml_customer_edit are M2 out of the box options you would expect to find those in the list, right?

Any thoughts?

Later edit:
Customer Attributes are only available on M2 Enterprise Edition.


texts: Magento 2 Can I disable Magento_Tax module?

texts: Tax is useless for my shop. Can I disable/remove the Magento_Tax module? If yes, how can I disable/remove it? Thanks.


texts: Adding wishlist button on homepage for newest products

texts:
I am a newbie .I have added a widget from admin panel to home page for displaying newest product.
But it does not show any wishlist button for those product.
What should I do for this?


texts: Magento 2 : Custom module email template is showing Luma header and footer?

texts:
I have created a custom form module, when I send email and the template showing Luma theme header and footer but for another emails everything loads from custom theme.

  Question : Why this is happening?

Any help would be appreciable.


texts: Magento 2: How to add additional block on checkout page?

texts:
I would like to override the below file & display my custom block in the li.
magento\vendor\magento\module-checkout\view\frontend\web\template\shipping.html

 // Mine need to call block created from Admin

If the block is enabled in the admin then it will show a custom li with the block data, otherwise it shows nothing.
Can we check directly in the .html file whether the block is enabled or not?


texts: I am working in magento 1.9.2.2.When a new customer registers, the message is displayed saying that the confirmation mail is sent but confirmation mail is not sent.Also I have already set system->configuration->customer->customer configuration->Require emails confirmation=yes.Should anything be done additionally.Kindly anyone guide me.


texts: Magento hide flat rate on orders over x.xx

texts:
I have set a Flat rate shipping of R100.00 (South African Rands) for all items less than R500.00. At the moment it is working. It loads if the orders are less than R500.

However the moment the order us greater than R500, I still get the Flat rate instead of just the Free shipping. How would I go about hiding the flat rate for items over R500 in Magento?

I am using Magento 1.9.0.1. Let me know if you require any clarification.


texts: Set Discount - Three categories, multiple options

texts:
We are trying to set up the following scenario with discounts in our Magento Store, we have tried everything with no luck.

Products:

Product A - Category A
Product B - Category B
Product C - Category C

Desire Discounts:

Option #1: If a customer has in cart Product A and Product B, apply 5 % discount
on Product B
Option #2: If a customer has in cart Product A and Product C, apply
10 % discount on Product C
Option #3: If a customer has in cart Product A, Product B and Product C,
apply 12 % discount on Product B and Product C

Our issue, for example, is that if someone has in cart Two Products A and Three Products B, the discount only applies once, when it should apply twice. (As there are two combos #1)

Any idea how we could solve this?

Any help will be appreciated

Thanks!!


texts: What piece of code is called on the Paypal Standard Payment success page?

texts:
since after each Paypal payment the order confirmation email is not sent, i wanted to "force" this to happen.

The easiest solution i found online was to edit the following if statement

    if (!$redirectUrl && $order->getCanSendNewEmailFlag()) {
        try {
            $order->sendNewOrderEmail();
        } catch (Exception $e) {
            Mage::logException($e);
        }
    }

on \app\code\core\Mage\Checkout\Model\Type\Onepage.php
but this will send an email even before the payment has been made.

So the only solution i can think about is to call sendNewOrderEmail() on the success payment page after the Paypal payment has been made.

The piece of code i was thinking of adding was something like (as appears on \app\code\core\Mage\Paypal\Model\Ipn.php)

    if (!$this->_order->getEmailSent()) {
        $this->_order->sendNewOrderEmail();
    }

but i really don't know where to put it in order to be called after the payment has been completed successfully.

Hope someone can help, thanks


texts: Registration is broken after switch to HTTPS

texts:
We switched our shop from HTTP to SSL / HTTPS.
After that, the user registration is broken.
When you type in your data and click at "register", you are re-directed to the registration page without doing anything..

Security settings:

secure_base_url = https://www.musikhaus-zoelch.de/
unsecure_base_url = https://www.musikhaus-zoelch.de/
SSL offloading = SSL_OFFLOADED
use secure URL in shop / backend = true

Cookie:

cookie lifetime = 3600
cookie path = /
cookie domain = .musikhaus-zoelch.de
use only http = false
restrict cookie mode = false

Shop: https://www.musikhaus-zoelch.de

Registration: https://www.musikhaus-zoelch.de/customer/account/create/

Magento Version 1.9.3.6

what can I do?


texts: Magento 2 : Override addtocart.phtml for all kinds of products

texts:
How can I override addtocart.phtml for all types of products, this code works fine only for simple and configurable products, but I want to override all kinds of products.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="Eltrino_HideAddCart::css/disableaddtocart.css"/>
    </head>
    <body>
        <referenceBlock name="product.info.addtocart">
            <action method="setTemplate">
                <argument name="template" xsi:type="string"> Module_Cart::catalog/product/view/addtocart.phtml</argument>
            </action>
        </referenceBlock>
        <referenceBlock name="product.info.addtocart.additional">
            <action method="setTemplate">
                <argument name="template" xsi:type="string"> Module_Cart::catalog/product/view/addtocart.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>


texts: Change shipping rate based on the weight or volume

texts: I have a question on shipping. Is possible to set a method that takes the volume or weight of the product and calculate the cost depending on a scale?


texts: How to upload Image using Avs Import in product?

texts:
I want to upload image by programmatically.

I have to imagefolder and
i put it media/import/imagefolder.
and My code is

<?php
require_once 'app/Mage.php';
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

 ini_set('display_errors', 1);
 ini_set('max_execution_time', 0);
 ini_set('memory_limit', '50024M');
$attrId = Mage::getSingleton('catalog/product')->getResource()->getAttribute('media_gallery')
->getAttributeId();
$path = Mage::getBaseDir('media').'\import'.DS;
echo $path;
$data = array();
echo "<br>";
echo "<pre>";
$files = glob($path.'*.jpg' ,  GLOB_BRACE);
//$path_parts = explode(".",$files);
    foreach($files as $key=>$value)
    {
        $filename = basename($value);
        //echo $filename;
        $path_parts = explode(".",$filename);

        unset($path_parts[1]);

        $data[] = array(
        'sku' => $path_parts[0],
        '_type' => 'simple',
        'status' => 1,
        'visibility' => 4,
        '_media_image'=> $value,
        '_media_attribute_id'=>$attrId,
        '_media_is_disabled' =>0,
        'image'=> $filename,
        'small_image'=> $filename,
        'thumbnail'=> $filename,

);
//$data = array_values($data);

    } print_r($data);
    try {
    /** @var $import AvS_FastSimpleImport_Model_Import */
    $import = Mage::getModel('fastsimpleimport/import');
    $import->processProductImport($data);
} catch (Exception $e) {
    print_r($import->getErrorMessages());
}

echo "Check Now";

?>

but Image not uploaded.

so how can i do?


texts: How to handle multi level array as input parameter from custom POST webservice in Magento2

texts:
We have request to create custom REST webservice for creating gift orders and we are successfully able to create order for single item but facing issues on taking multi items as input.

Can anyone help please?

We have created below files to handle

CreateOrderInterface

interface CreateOrderInterface
{

    /**
     * @param string $giftCardCode
     * @return boolean;
     * @throws \Exception
     */
    public function checkGiftCard($giftCardCode);

    /**
     * @param XYZ\GiftCard\Api\JsondataInterface $orderData
     * @param XYZ\GiftCard\Api\AddressdataInterface $customerAddress
     * @param XYZ\GiftCard\Api\BillingdataInterface $billingAddress
     * @param XYZ\GiftCard\Api\ShippingdataInterface $shippingAddress
     * @param XYZ\GiftCard\Api\ItemsdataInterface $items
     * @return string;
     * @throws \Exception
     */
    public function createOrder($orderData, $customerAddress,$billingAddress,$shippingAddress,$items);
}

createOrder Model

class createOrder
{
    /**
     * @param \XYZ\GiftCard\Api\Kensium\GiftCard\Api\JsondataInterface $jsonOrderData
     * @param \XYZ\GiftCard\Api\Kensium\GiftCard\Api\AddressdataInterface $customerAddress
     * @param \XYZ\GiftCard\Api\Kensium\GiftCard\Api\BillingdataInterface $billingAddress
     * @param \XYZ\GiftCard\Api\Kensium\GiftCard\Api\ShippingdataInterface $shippingAddress
     * @param \XYZ\GiftCard\Api\Kensium\GiftCard\Api\ItemsdataInterface $items
     * @return array|string
     * @throws \Exception
     * @throws \Magento\Framework\Exception\LocalizedException
     * @throws bool
     */
    public function createOrder($jsonOrderData, $customerAddress, $billingAddress, $shippingAddress,$items)
    {
        $invalidType = array();
        $invalidSku = array();
        $invalidAmount = array();
        print_r($jsonOrderData->getItems());die;
    }
}


texts: ERROR The table 'catalog_product_index_price_bundle_sel_tmp' is full

texts:
There are 10k products, websites (over 50 ) and multiple store (i.e. over 100) in my web-store and I am getting following error during magento re-indexing process.

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[HY000]: General error: 1114 The table 'catalog_product_index_price_bundle_sel_tmp' is full' in /home/staging2/public_html/newclubcolors/lib/Zend/Db/Statement/Pdo.php:234

I have checked lot of information on google but able to resolve this problem.

According to them, i have increased the values of mysql variables but still, i am getting table full error error

max_heap_table_size = 8096M:autoextend
tmp_table_size = 4096M:autoextend
innodb_data_file_path = ibdata1:4G:autoextend

Any help would be appreciated.

Thanks!


texts: how to edit the cart page? checkout_cart_index magento 2

texts: How to edit a cart page? checkout_car_index. Every time I edit the layout, the value next to the freight and the discount value as well. It seems that it is not possible to move on that page correctly. Can someone help me? The code is the same standard code as in the vendor. Does magento have any rules in checkout_cart_index? because every time I move a block, the freight cost stops showing up.


texts: How to get paypal partner name and vandor name for credit card from paypal pro setup in magneto 2

texts: I am trying set up paypal pro in magneto 2 with sand box credentials.Here for paypal pro it need partner ,user,vendor,password.Can any please tell me that from paypal account, from where can i get mainly vendor and partner then user and password details.


texts:
I've set up PayPal Express Checkout, however, I'm in a position now where I need to test it.
The button does not appear on the cart page.

Printing the following method reveals that PayPal is enabled:

$this->getMethods('methods');

However, the following is empty for the PayPal Express Checkout:

$this->getMethodHtml($method);

Without the button, and the associated data attached to it, I cannot navigation to /paypal/express/start because I get a security error.

Shortcut on Shopping Cart is marked as Yes, so I'm struggling to understand why it's not appearing.


texts: when i add product in magento 2 from iphone the image change to landscape

texts: I am using codazon theme for Magento 2 and I am facing issue when I open Magento 2 admin from iPhone and start adding images for product all of sudden the images change to landscape, all other places working fine from laptop browser, android, everything working fine but when adding from iPhone the image change to landscape. need help


texts: Paypal Payflow Fraud Transaction - (Carding) on Magento 2.2.2

texts:
My website is running on Magento 2.2.2 and I am using Paypal Payflow as a payment method.

The issue that we are facing is someone with different IP addresses is using our website for Carding and my PayPal account has been deactivated. They are saying that your account is getting suspicious transactions Until you will not fix this issue we will not enable your account.

Please suggest me a solution so that I would be able to re-open my PayPal account. I would really appreciate your help and consideration.

Please let me know if you need any other details.


texts:
How to delete design configuration?
How to delete design configuration?


texts:
We are trying to migrate our DB to MySQL 5.7 on Percona XtraDB cluster.

In the MySQL log file there are errors preventing some operations to be performed.

The errors visible with the current setting are of 2 types:

  2019-06-24T08:00:03.187120Z 99531 [ERROR] WSREP:
  Percona-XtraDB-Cluster prohibits use of GET_LOCK with pxc_strict_mode
  = ENFORCING

  or

  2019-06-24T08:39:21.115870Z 100000 [ERROR] WSREP:
  Percona-XtraDB-Cluster prohibits use of DML command on a table
  (log_url) without an explicit primary key with pxc_strict_mode
  = ENFORCING or MASTER

Currently the DB cluster is set with

pxc_strict_mode=ENFORCING

Note, we have tried to set up a different mode and locked for stabilizing the BD using the following mode without success

pxc_strict_mode=PERMISSIVE

But the result is instability at the engine level ending in the whole database being unresponsive and requiring a reboot.

However when setting the mode to PERMISSIVE we have the following errors matching the one above:

  2019-06-18T09:30:55.552852Z 753 [Warning] WSREP:
  Percona-XtraDB-Cluster doesn't recommend use of GET_LOCK with
  pxc_strict_mode = PERMISSIVE

  2019-06-18T09:30:55.570212Z 753 [Warning] WSREP:
  Percona-XtraDB-Cluster doesn't recommend use of RELEASE_LOCK with
  pxc_strict_mode = PERMISSIVE

Or

  2019-06-17T15:30:18.766308Z 764 [Warning] WSREP:
  Percona-XtraDB-Cluster doesn't recommend use of DML command on a table
  (catalog_category_product_index_idx) without an explicit
  primary key with pxc_strict_mode = PERMISSIVE

  2019-06-17T15:30:18.770449Z 764 [Warning] WSREP:
  Percona-XtraDB-Cluster doesn't recommend use of DML command on a table
  (catalog_category_product_index_enbl_idx) without an explicit
  primary key with pxc_strict_mode = PERMISSIVE

  2019-06-17T15:30:18.795257Z 764 [Warning] WSREP:
  Percona-XtraDB-Cluster doesn't recommend use of DML command on a table
  (catalog_category_anc_categs_index_idx) without an explicit
  primary key with pxc_strict_mode = PERMISSIVE

  2019-06-17T15:30:18.797970Z 764 [Warning] WSREP:
  Percona-XtraDB-Cluster doesn't recommend use of DML command on a table
  (catalog_category_anc_categs_index_idx) without an explicit
  primary key with pxc_strict_mode = PERMISSIVE

Having this information shows that there are missing primary keys on at least these tables:

catalog_category_product_index_idx
catalog_category_product_index_enbl_idx
catalog_category_anc_categs_index_idx
… and possibly others

Can we add a primary key on these tables ? or is there a setting that I missed regarding the following configuration with the following environment ?`

Environment is composed of:

o   MySQL 5.7

o   Percona XtraDB cluster

o   Magento 1.9.4.1


texts: To Create single product as both simple and downloadable products

texts:
I want to publish a book in both format(i.e papaer back hard copy as well as downloadable). Is there any solution for it? Please do the needful.
Thank you in advance.


texts: Magento 2 migration issue with payment transaction id

texts:
We are able to migrate data successfully with sales payment transaction table.

map.xml

<transform>
                <field>sales_payment_transaction.additional_information</field>
                <handler class="\Migration\Handler\SerializeToJson" />
</transform>

Which is not transforming/working at the time of migration.

For Example
    Expected Result:

Instance          :      M1
Table Name      :     sales_payment_transaction
Column Name  :     additional_information
Serialized Data :    A:1:{s:19:"real_transaction_id";s:22:"5574217307766210204089";}

Instance          :      M2
Table Name      :     sales_payment_transaction
Column Name  :     additional_information
Json Data        :    {"real_transaction_id":"5574217307766210204089"}

Actual Result:

 Instance:      M1
Table Name      :     sales_payment_transaction
Column Name  :     additional_information
Serialized Data :    A:1:{s:19:"real_transaction_id";s:22:"5574217307766210204089";}

Instance          :      M2
Table Name      :     sales_payment_transaction
Column Name  :     additional_information
Json Data        :     A:1:{s:19:"real_transaction_id";s:22:"5574217307766210204089";}

The above example not working at the time of DELTA mode. Please suggest on this

Exception log

report.CRITICAL: a:1:{s:19:"real_transaction_id";s:22:"5682952820116120004012";}Unable to unserialize value. Error: Syntax error {"exception":"[object] (InvalidArgumentException(code: 0): a:1:{s:19:\"real_transaction_id\";s:22:\"5682952820116120004012\";}Unable to unserialize value. Error: Syntax error at /var/www/html/tupperware/vendor/magento/framework/Serialize/Serializer/Json.php:39)"} .


texts: How to get cart rule id when cart rule apply

texts: How to get shopping cart rule information? I need to change/add custom logic when the cart rule apply in the shopping cart page.


texts: How to update header login link using ajax Magento 2

texts:
I have created sections.xml as below:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="customer/ajax/login">
        <section name="header"/>
    </action>
</config>

But I have found in response "section source is not supported".

I want to update highlighted part in above image.


texts: magento 2 setup:static-content:deploy execution time error

texts:
I am trying to install quick setup of theme also did but css and js is not loading so i run command.
php bin/magento setup:static-content:deploy -f
but every time getting error like execution time
is there any solution?


texts: Set tax amount magento 2.1 programmatically

texts: I want to set my calculated tax amount in cart, review etc., in Magento 2.1. I dont know how to set tax amount programmatically. kindly help me out!!


texts: How to set and get session in magento2.2.3?

texts:
I have used below code to set the session in Observer file:

namespace VendorName\ModueleName\Observer;

use Magento\Framework\Event\ObserverInterface;

class ClassName implements ObserverInterface
{
    protected $customerSession;

    public function __construct(
        \Magento\Customer\Model\Session $customerSession
    ){
        $this->customerSession = $customerSession;
    }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $this->customerSession->setIpAddress($_SERVER['REMOTE_ADDR']);
    }
}

I want to access this session at app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php fetch() action.

I use the below code:

protected $customerSession;

public function __construct(
        \Magento\Customer\Model\Session $customerSession
    ){
        $this->customerSession = $customerSession;
    }

$this->customerSession->getIpAddress();

Please help.


texts:
I'm running a Magento 2.3.2 I noticed that the update.log file in the var folder grows rapidly to over 70GB
as per the below pic
https://i.ibb.co/1K07SHw/2019-12-17-010144.jpg


texts:
Can anyone help me how to fetch the all shipping methods available in system->config->shipping Methods programatically.

I  have used the below code:
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();

Get the result like below:

but iam unable to find what are methods names:

Result:

[freeshipping] => Mage_Shipping_Model_Carrier_Freeshipping Object
    (
        [_code:protected] => freeshipping
        [_isFixed:protected] => 1
        [_rates:protected] =>
        [_numBoxes:protected] => 1
        [_freeMethod:protected] => free_method
        [_customizableContainerTypes:protected] => Array
            (
            )

        [_debugReplacePrivateDataKeys:protected] => Array
            (
            )

        [_data:protected] => Array
            (
                [id] => freeshipping
                [store] =>
            )

        [_hasDataChanges:protected] => 1
        [_origData:protected] =>
        [_idFieldName:protected] =>
        [_isDeleted:protected] =>
        [_oldFieldsMap:protected] => Array
            (
            )

        [_syncFieldsMap:protected] => Array
            (
            )

    )

[tablerate] => Mage_Shipping_Model_Carrier_Tablerate Object
    (
        [_code:protected] => tablerate
        [_isFixed:protected] => 1
        [_default_condition_name:protected] => package_weight
        [_conditionNames:protected] => Array
            (
                [0] => package_weight
                [1] => package_value
                [2] => package_qty
            )

        [_rates:protected] =>
        [_numBoxes:protected] => 1
        [_freeMethod:protected] => free_method
        [_customizableContainerTypes:protected] => Array
            (
            )

        [_debugReplacePrivateDataKeys:protected] => Array
            (
            )

        [_data:protected] => Array
            (
                [id] => tablerate
                [store] =>
            )

        [_hasDataChanges:protected] => 1
        [_origData:protected] =>
        [_idFieldName:protected] =>
        [_isDeleted:protected] =>
        [_oldFieldsMap:protected] => Array
            (
            )

        [_syncFieldsMap:protected] => Array
            (
            )

    )

Thanks


texts:
I'm trying to use the message manager in magento2 (admin side) by object injection but when i add it to my controller - my controller doesn't run.

class Example
{
    protected $_messageManager;

    public function __construct(
        \Magento\Framework\Message\ManagerInterface $messageManager
    ) {
        $this->_messageManager = $messageManager;
    }

    public function method( ) {
        ..
        $message = '...';
        $this->_messageManager->addError($message);
        ..
    }
}


texts: Display all products through custom block module

texts: How to display all the products through custom block module on frontend in magento?


texts: Alter required attribute for customer attribute

texts:
I am migrating customers from Mage 1 to Mage 2.

The mage 1 instance did not require first name and last name (it was used as a back end repository for a mobile app).

When I am importing the customers it is telling me that first name and last name are required.

I know that in mage 1 I was able to alter a property and set required to false.

I am unsure on how to do this in mage 2.

Ideally I would like to set to false, do the import and then set to true when the script is finished.


texts: Why sales_order_item and quote_item being populated with configurable and simple product?

texts:
Whenever I created the product item I always found that the sales_order_item is populated with two rows for each product for example :

select quote_item_id,expected_delivery_time, sku,product_type from sales_order_item;

+---------------+------------------------+---------------+--------------+
| quote_item_id | expected_delivery_time | sku           | product_type |
+---------------+------------------------+---------------+--------------+
|           109 | 2017-10-20 17:00:00    | WS05-L-Black  | configurable |
|           110 | NULL                   | WS05-L-Black  | simple       |

I have successfully add the expected_delivery_time using this snippet code when using :

    /**
     * @var \Magento\Quote\Model\Quote\Item $item
     */
    foreach ($items as $item) {
        ....
        if (!empty($expectedDays)){
            $deliveryTime = $this->_getPreparedDateTime($deliverDay);
            $item->setExpectedDeliveryTime($deliveryTime);
            $item->save();
        }
    }

But above code only set the expected_delivery_item for configurable product_type not with the simple, although it is created by the same sku and the same product.

Please somebody explain to me why magento 2 created two rows for every product in the sales_order_item and quote_item table?

And I found out that whenever I login to the admin panel and create my own order, the two rows become simple all of them.

Why is this different when the user create an order from the front-end site it is configurable and simple but not from the admin panel?

And the last is how do set the expected_delivery_date for the simple product created in the sales_quote_item and quote_item table?


texts: Programatically clear product group prices - Invalid argument supplied for foreach()

texts:
I am trying to programatically clear a product's group prices within a custom module. Thisi s my code:

Mage::setIsDeveloperMode(true); // for debug only
try
{
    $product = Mage::getModel('catalog/product')->load($productId);
    $product->setGroupPrice(null);
    $product->save();
}
catch (Exception $ex)
{
    echo "Error: ". $ex->getMessage();
}

When this code executes, I get the following exception:

  Warning: Invalid argument supplied for foreach()  in
  /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
  on line 1180

In the system.log file, I see allot of these entries:

  2016-03-17T18:01:06+00:00 ERR (3): Warning: Invalid argument supplied
  for foreach()  in
  /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
  on line 1180 2016-03-17T18:01:06+00:00 ERR (3): Recoverable Error:
  Argument 3 passed to
  Mage_Catalog_Model_Resource_Abstract::_canUpdateAttribute() must be of
  the type array, null given, called in
  /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
  on line 1225 and defined  in
  /home/www-data/public_html/app/code/core/Mage/Catalog/Model/Resource/Abstract.php
  on line 543 2016-03-17T18:01:06+00:00 ERR (3): Recoverable Error:
  Argument 3 passed to
  Mage_Eav_Model_Entity_Abstract::_canUpdateAttribute() must be of the
  type array, null given, called in
  /home/www-data/public_html/app/code/core/Mage/Catalog/Model/Resource/Abstract.php
  on line 545 and defined  in
  /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
  on line 1254 2016-03-17T18:01:06+00:00 ERR (3): Warning:
  array_key_exists() expects parameter 2 to be array, null given  in
  /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
  on line 1256

Any idea what might be causing this? The same code on my dev magento setup works, but in production magento, this error started to appear, so I am a little confused.


texts: How to set Tiered Pricing on Configurable Products using Price Rules

texts:
All of my googling tells me that Magento 2 no longer supports price tiers for configurable products. Only simple products can have price tiers.

The results also point me to using Price Rules.

How do I setup MARKETING > Catalog Price Rule(s) to get price tiers at different order quantities?

The pages are not very intuitive and I cannot find how to set quality break points.


texts:
I have filled my database with a bunch of test data.  Before going live I want to clear all the test orders in the database. I view my database using cPanel usually.

What is the best way to clear ALL orders, yet keep all my customers and their data?


texts:
I have to implement the following scenario.
The default sort order in category (by position) should ignore the position set for the products in the category.
Instead when sorting by position it should follow this rule:

Products added in the last X days at the top (X is configurable).
Products that have a discount (special price or catalog rule) at the bottom.
Rest of the products in between the 2 cases above.

My approach is to rewrite Mage_Catalog_Model_Resource_Product_Collection::addAttributeToSort(). If the attribute code passed to it is position I should execute my custom code. Otherwise parent::addAttributeToSort().

But what should my custom code be?

All products are simple or configurable.

Running a cron that updates the positions from time to time based on my rules is not a valid option in this case.


texts: Magento 2 add custom column in product grid?

texts:
How can I add new column in product grid when you create new order from admin panel ? see this screenshot for more information.

i need product qty in new column?


texts: Add asociated array to the Values retrieved before

texts:
I have this code, witch retrieves the values I need:

<?php foreach($allProducts as $p): ?>
 <?php if(!$p->isSaleable()) continue; ?>
 <?php $out=$p->getAttributeText($pAtt->getName()); ?>
 <?php $frontValues[$out]=$out; ?>
 <?php $colors=$p->getData(strtolower($pAtt->getName())); ?>
<?php endforeach ?>

This is the markup that places this to my page:

<a id="a-<?php echo $out ?>"><?php echo implode('

">', $frontValues); ?>

The problem is that the echo $out is retrieved only ones, but there are more items in the array and all of them get's the same value, witch is not good for me.

The problem is that I can't figure out, how to make an Asociated Array to the values of $frontValaues array and add accordingly assign the correct id to the retrieved item.

I tryed adding

<?php $colorValues[$colors]=$colors; ?>

in foreach, and then replicating the same implode method, like this:

<a id="a-<?php echo implode('', $colorValues); ?>"><?php echo implode('

">', $frontValues); ?>

but then this array is adding all the values to the ID.

How can I separate them? So the only correct retrevied value would be asociated to the .

I'm quite a newby here, so any suggestion is welcome.

Thanks,

Full code and working for anyone who may be interested in it

                  <?php if($_product->isConfigurable()): ?>
                    <?php $attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product) ?>
                    <?php if(count($attributes)): ?>

                      <?php foreach($attributes as $att): ?>
                        <?php $pAtt=$att->getProductAttribute();
                          if ($pAtt->getFrontendLabel() != 'Color') continue;
                          //get the child products
                          $allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product);
                          $frontValues =array(); ?>

                         <?php
                            $output = array();
                            foreach($allProducts as $p){
                              if(!$p->isSaleable()) continue;
                              $output[$p->getAttributeText($pAtt->getName())] = array(
                                            'out' => $p->getAttributeText($pAtt->getName()),
                                            'color' => $p->getData(strtolower($pAtt->getName()))
                                          );
                            }
                         ?>
                          <?php foreach($output  as $key => $value) : ?>

<a id="a-<?php echo $value['color'] ?>"><?php echo $value['out'] ?>

                            <?php endforeach; ?>

                      <?php endforeach ?>

                    <?php endif ?>
                  <?php endif ?>


texts: Why does removing the 'WHERE product =' clause in this query not show all products?

texts:
I'm doing a code review for a search engine extension and am testing this query on my database:

SELECT product_id, SUM(value) FROM catalog_category_product_index
LEFT JOIN catalog_category_entity_text vc
ON category_id = vc.entity_id
WHERE product_id = 5281 AND vc.attribute_id = 484

The results are:

product_id   SUM(value)
5281         24000

However, when I remove the product_id = 5281 clause and run this:

SELECT product_id, SUM(value) FROM catalog_category_product_index
LEFT JOIN catalog_category_entity_text vc
ON category_id = vc.entity_id
WHERE vc.attribute_id = 484

I expect a list of all products with their corresponding values. Instead, I get this:

product_id   SUM(value)
4871         2143200

I'm obviously missing something, and it's probably something obvious. Any ideas?


texts: Magento2 - Layered Navigation on category with children

texts:
I am fairly new with Magento 2 and never worked with Magento 1. I'm working an a Magento 2 theme now, which includes a sidebar with price slider and category filter. Magento 2 supports this (almost) with Layered Navigation.

My question is, why does the Layered Navigation not show up on category overviews with children. For example I want to add it to this page: http://sebwite.hypernode.io/men.html.

I'v created my own block with price slider (so without Layered Navigation). This is a simple form with GET request. But when the param price=20-50 is added to the url, nothing happens in my theme. If I activate the Luma theme, the products are sorted.

How can I create a price slider that will work on every category page? Do I need to add an attribute filter myself to the product collection, or is there an easier way?

Thanks.


texts:
I have not been able to find a way to load tax rates in CE 1.9 that are effective from a future date, or to enter increase/decrease in tax rate at a future date.  There appear to be no tax validity periods anywhere.
Can anyone help please.


texts: Remove street address field and required attribute from shipping address

texts:
I have a very custom use for Magento and I'm trying to remove street address from the checkout.  Currently I have:

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']['street'] = [
    'component' => 'Magento_Ui/js/form/components/group',
    'required' => false,
    'dataScope' => 'shippingAddress.street',
    'provider' => 'checkoutProvider',
    'sortOrder' => 1005,
    'type' => 'group'
    ];

     return $jsLayout;
 }
}

Unfortunately, while this seems to have removed the street address and stopped it from being required when entering shipping address, once I continue to the Review & Payment page and press "Place Order" it provides the following error, stopping me from proceeding:

  Please check the shipping address information. street is a required field.

How can I stop this check and allow it to proceed?

This solution suggests that I can remove the required aspect of fields with jquery, but where would I put this js file and get magento to load it on the Review and Payment page?


texts:
I have problem with search products on magento 1.9.4.1

i have this error

AH01071: Got error 'PHP message: PHP Fatal error: Call to undefined method Mage_CatalogSearch_Model_Resource_Fulltext::getFoundData() in /var/www/vhosts/donordrives.com/m1.donordrives.com/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php on line 148\n'

I was looking for this problem, but did not understand how to correct the error.

Please tell me how to solve it.


texts: We currently have a multistore Magento 2 set up, we have a custom maintenance page set up using /pub/errors/default/503.phtml, this shows fine when the sites go into maintenance mode, we however want to show a translated message on each page rather than it just being in English. Is this possible?


texts: Magento 2: Customizable Options disappear after upgrade to 2.1.7 from 2.1.4

texts:
We've upgraded Magento 2 from 2.1.4 to 2.1.7, after the successful upgrade we see some customize-able options are not there, please find the below link:

Thanks


texts: No product data returned for GraphQL query if stock not assigned

texts:
I have a Magento 2.3.5 site with multiple websites and multiple stock sources. Let's say I want to look up "mysku" in the UK store (store code: uk), which belongs to the UK website. Let's say the UK website uses Birmingham stock, but it turns out that while "mysku" is associated with the UK website, it has no allocation in Birmingham stock.
The request has a header of "store" with a value of "uk". The request body looks like this:
{
  products(filter: {sku: {eq: "mysku"}}) {
    items {
        name
        sku
        url_key
    }
  }
}

The response comes back like this:
{
  "data": {
    "products": {
      "items": []
    }
  }
}

I've been unable to find anything in the docs, or anywhere for that matter, that says missing stock allocation equals missing data. It doesn't seem like that should be the expected result, especially considering I can specify a store code relating to a website to which the product doesn't even belong, but if that store is using "default stock" then I get data back. So... not associated to the right website, that's OK I still get results, but not associated to the right stock and I get nothing?
Is this right?


texts: Magento 1: Minimum Order Amount excluding shipping cost?

texts:
I have an issue with Minimum Order Amount in Magento 1. This value I set up in Backend is including shipping cost too. Minimum Ordered Amount is actually Total Amount, can I set up minimum order amount only for total of product costs?

Here is an example: Product price is 45 USD, Shipping cost 10 USD, Minimum Order Amount 100 USD. If you order 2 pieces your Total Amount will be 2 * 45 + 10 = 100 and Magento accepts it. I would like to change the minimum order amount to exclude those 10 USD shipping cost.


texts: How Can I override vendor/magento/magento2-base/lib/web/extjs/ext-tree.js file for backend in magneto2?

texts: How Can I override vendor/magento/magento2-base/lib/web/extjs/ext-tree.js file for backend? I want to customize this file which will effect on backend admin


texts:
I'm trying to filter my products using the method in the title, but when I run it, nothing happens.

Is this not the way to filter products by price?


texts:
I have some modules that I'm not going to use. E.g Temando_Shipping, MSI modules, GraghQl modules,...

Should I disable them using config.php or should I remove them from the codebase using composer replace?

Which one is the better approach and has a better performance result?


texts: Magento2: how to delete summary field from review form

texts:
I want delete filed Summary from reviews product form.

In file vendor/magento/module-review/view/frontend/templates/form.phtml

I comment line:

    <?= $block->escapeHtml(__('Summary')) ?>

        <input type="text" name="title" id="summary_field" class="input-text" data-validate="{required:false}" data-bind="value: review().title" />

Currently, the "Summary" field is not displayed. But when trying to add reviews, I get an error that I need to fill this field. How to solve it?

I try delete this filed from reviews form:
https://prnt.sc/o2v4w0

I delete this in form.html and now not displayed:
https://prnt.sc/o2v56q

But when I try add review:
https://prnt.sc/o2v5kl
Then error because system still required this field.


texts: Passing the Product id and form key but not adding to cart in magento2

texts:
passing product id and form key through url but product not added to cart in magento2.

http://127.0.0.1/magento2.3/checkout/cart/add/uenc/aHR0cDovLzEyNy4wLjAuMS9waGlsaXBzX0hVRV8yXzAvZmVlZC9leHBvcnQvZXhlY3V0ZT9jYWxsYmFjaz1qUXVlcnkxMTI0MDM0MDU1MTE2ODg3NTA4NTNfMTU1NDEyNjcxMzYxMyZpZD0xOCZtb2RlPWNvbnRpbnVlJnJhbmQ9MC4wNTYyODUxODIzMTAyODkyMyZfPTE1NTQxMjY3MTM2MTUmaXNBamF4PXRydWU%2C/product/1/form_key/uiYQPpblGQ6hsldy


texts: Capistrano & Magento - Previewing new deploy and manually update symlink

texts:
I am using a Capistrano deployment workflow for a Magento project.

On deploy Capistrano builds this Magento project on the server using https://github.com/Cotya/magento-composer-installer.

The issue is sometimes my Magento modules don't install correctly and I need to clear the cache, reindex or some other task to get everything 100%. The issues occur sporadically so I haven't been able to script a fix into the deployment process.

What I would like is on deploy Capistrano does not change the symlink to the new build straight away. Instead I am able to preview the site on another link, fix what needs to be fixed, then change the symlink manually.

Is this possible to set up using Capistrano?

If not, my other solution to this is to use the Magento maintenance flag however I would rather avoid having to put the site in maintenance. Open to other idea's as well!

Thanks


texts: Magento 2: TinyMCE editor is breaking CMS directives nested in html attributes

texts:
Using TinyMCE 3.4.7 (Magento 2) and I'm having an issue where when I insert Magento CMS directives into an html attribute, the resulting html ends up completely broken. For example:

will be converted into:

by the editor. Is there a way to get the TinyMCE editor to ignore everything inside the Magento curly brace {{  }} cms directives? Or another solution to this issue?


texts: Magento 2 : Add custom field in product collection

texts:
How to add custom field in product collection? I want to add discount value field in product collection.
When I print product collection, it's output like this :
[0] => Array
        (
            [entity_id] => 1
            [attribute_set_id] => 15
            [type_id] => simple
            [sku] => 24-MB01
            [has_options] => 0
            [required_options] => 0
            [created_at] => 2021-01-27 09:13:37
            [updated_at] => 2021-03-30 15:01:25
            [cat_index_position] => 0
            [price] => 40.000000
            [tax_class_id] => 0
            [final_price] => 16.000000
            [minimal_price] => 16.000000
            [min_price] => 16.000000
            [max_price] => 16.000000
            [tier_price] =>
        )

I want like this :
[0] => Array
        (
            [entity_id] => 1
            [attribute_set_id] => 15
            [type_id] => simple
            [sku] => 24-MB01
            [has_options] => 0
            [required_options] => 0
            [created_at] => 2021-01-27 09:13:37
            [updated_at] => 2021-03-30 15:01:25
            [cat_index_position] => 0
            [price] => 40.000000
            [tax_class_id] => 0
            [final_price] => 16.000000
            [minimal_price] => 16.000000
            [min_price] => 16.000000
            [max_price] => 16.000000
            [tier_price] =>
            [discount_value] => 60.00000
        )

How can I add that field?
Please help me.


texts:
I've (as best I know how) written a small PHP front controller that allows me to quickly write scripts without having to worry too much about security, css etc as they are handled automaticially.

Annoyingly though, it looks like magento's bootstrap.php uses an autoloader and shutdown function as well, which leaves me with a conflict when including bootstrap.php in my scripts.

Message : Class file /home/customer/www/{{domain name}}/public_html/{{myapp folder}}/{{myapp subfolder}}/classes/zend\servicemanager\pluginmanagerinterface.php.php does not existMessage : Class file /home/customer/www/{{domain name}}/public_html/{{myapp folder}}/{{myapp subfolder}}/classes/paragonie_sodium_compat.php.php does not exist

Warning: register_shutdown_function(): Invalid shutdown callback '' passed in /home/customer/www/{{domain name}}/public_html/{{myapp folder}}/{{myapp subfolder}}/bootstrap.php on line 18

i've removed the domain name, application folder and subfolder for obvious reasons, but can't find a solution where I can run my own system with magento bootstrapped for certain functions.


texts: Changing the product custom option renderer

texts:
I have custom options that are added to certain products dynamically using the catalog_controller_product_view event and my own observer.

Related: How to add dynamic Select Custom Options in Observer

I'd like to now use an option renderer other than the default. Ideally, I'd like to set my own type field to the option when created so that it uses my own value, ie:

$optionModel = Mage::getModel('catalog/product_option')
    ...
    ->setType('my_option_type')
    ...

This, of course, requires my custom option type to have an associated Block, Model, etc. This also seems to require rewriting the Mage_Catalog_Model_Product_Option class to include my custom option type.

Unfortunately, the Magento team didn't think these option renderers would have been useful as templates, as the markup is essentially all created in the getValuesHtml() method inside the option's associated block class (ie. Mage_Catalog_Block_Product_View_Options_Type_Select)

How can I set my own renderer (preferably as a template, none of this sloppy getValuesHtml() stuff) to a custom option that is created dynamically on product view?

Really, all I need to do is add some additional data attributes to each option value's input element.


texts: Magento 2: Admin returns 404 using NGINX/PHP 7

texts:
I'm attempting to setup a local development version of Magento 2. I'm importing the database from a currently running Magento installation. The site works correctly, but I'm unable to access the admin page.

I'm using PHP 7, Magento 2 and NGINX with the following configuration:

upstream fastcgi_backend {
  server  unix:/run/php/php7.0-fpm.sock;
}

server {
  listen 80;
  server_name magento.local;
  set $MAGE_ROOT /home/vagrant/Code/magento;
  include /home/vagrant/Code/magento/nginx.conf.sample;
  error_log  /var/log/nginx/magento.dev-error.log error;
  access_log /var/log/nginx/magento.dev-access.log;
}

The server returns 404 when visiting /admin (confirmed URL from php bin/magento info:adminuri)

There seems to be a fair few issues posted but I've yet to find a solution! Any advice would be greatly appreciated.


texts: Magento 1 Update configurable stock based on child products stocks

texts: Some times Magento will not update the stock of the configurable product if there is any stock change happened to its child products. Usually this happens when some third party modules creating orders on magento.


texts: Datepicker not working in Magento 2.4 frontend

texts:
I am trying to add datepicker in Magento 2.4 frontend checkout page. But its giving following error -
knockout.js:3381 Uncaught TypeError: Unable to process binding "datepicker: function(){return { storage:value} }"
Message: $el.datepicker is not a function
    at init (delivery-date.js:20)
    at knockout.js:3358
    at Object.ignore (knockout.js:1470)
    at knockout.js:3357
    at Object.arrayForEach (knockout.js:159)
    at applyBindingsToNodeInternal (knockout.js:3343)

My code is - In .phtml file
<input class="input-text" type="text" autocomplete="off" data-bind="
    hasFocus: focused,
    datepicker: { storage: value },
    attr: {
        value: value,
        name: inputName,
        placeholder: placeholder,
        disabled: disabled
    }" />

In .js file
define([
    'jquery',
    'uiRegistry',
    'Magento_Ui/js/form/element/date',
    'ko',
], function ($, registry, Date, ko) {
    var format = 'mm/dd/yy';
    ko.bindingHandlers.datepicker = {
        init: function(element, valueAccessor, allBindingsAccessor) {
            var $el = $(element);
            var initOptions = {
                        minDate: 0,
                        dateFormat:format,
                        showTimepicker: false

                    };
            //initialize datepicker with our own options
            $el.datepicker(initOptions);

            if(initOptions.dateFormat)
            {
                $el.datepicker( "setDate", initOptions.dateFormat );
            }

            var writable = valueAccessor();
            if (!ko.isObservable(writable)) {
                var propWriters = allBindingsAccessor()._ko_property_writers;
                if (propWriters && propWriters.datepicker) {
                    writable = propWriters.datepicker;
                } else {
                    return;
                }
            }
            writable($(element).datepicker("getDate"));

        },
        update: function(element, valueAccessor)   {
            var widget = $(element).data("DateTimePicker");
            //when the view model is updated, update the widget
            if (widget) {
                var date = ko.utils.unwrapObservable(valueAccessor());
                widget.date(date);
            }
        }
    };
    return Date;
});

Please help me to fix this issue.


texts:
I am trying to limit the search results returned when doing a product search. The client wants to return only one option at a time. This is because their customers know the skus and dont want to see all the other skus that are similar.

By searching this way they will get an exact search. I found the search_result.xml file that if I update to 1 in the size I achieve my result.

The problem is I know not to edit inside the vender/magento files. How do a make this file to override it. Where do i begin as I am new to magento.

I understand how the theme files overwrite design things. However this is a backend thing. I would also like to add code that will show if no results are found to display something like we are currently out of stock.


texts: How to create custom top link customer for customer group in Magento 1

texts:
I create a top link, but i want it show if customer login has groupId = 2. Currently, if the group id is different from 2, it will still display <li> </li> but not My Text. How to fix it, please help me

block file:

public function __construct() {
    parent::__construct();
    if(Mage::getSingleton('customer/session')->isLoggedIn()) {
        $customerData = Mage::getSingleton('customer/session')->getCustomer();
        if ($customerData->getGroupId() == 2) {
            $text = $this->__('My Text');
            $this->_label = $text;
            $this->_title = $text;
            $this->_url = $this->getUrl('url');
        }
    }
}

layout xml file:

<default>
    <reference name="top.links">
        <block type="custom/links" name="custom_link"/>
        <action method="addLinkBlock" ifconfig="custom/main/display_credit_link_in_top_menu"><blockName>custom_link</blockName><liParams>class='mini-top-cart'</liParams></action>
    </reference>
</default>


texts: Magento 2: setPageSize not working in block

texts:
I am trying to get another product collection in the relate product
  list block. However, I cannot set the page size for the new
  collection. it always get all product of the system

Follows are my code.
di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Catalog\Block\Product\ProductList\Related" type="AIS\Custom\Block\Product\ProductList\Related" />
</config>

catalog_product_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Catalog\Block\Product\View" name="custom.age.indicator.block" template="AIS_Custom::ageindicatorblock.phtml" cacheable="false"/>
        </referenceContainer>
        <referenceBlock class="AIS\Custom\Block\Product\ProductList\Related" name="catalog.product.related">
                <arguments>
                    <argument name="type" xsi:type="string">related</argument>
                </arguments>
                <block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="related.product.addto" as="addto">
                    <block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare"
                            name="related.product.addto.compare" as="compare"
                            template="Magento_Catalog::product/list/addto/compare.phtml"/>
                </block>
        </referenceBlock>
    </body>
</page>

and the block php

<?php
namespace AIS\Custom\Block\Product\ProductList;

use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Framework\View\Element\AbstractBlock;

class Related extends \Magento\Catalog\Block\Product\ProductList\Related {

    //override get item function
    protected function _prepareData()
    {
        $product = $this->_coreRegistry->registry('product');
        /* @var $product \Magento\Catalog\Model\Product */

        $this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect(
            'required_options'
        )->setPositionOrder()->addStoreFilter();

        if ($this->moduleManager->isEnabled('Magento_Checkout')) {
            $this->_addProductAttributesAndPrices($this->_itemCollection);
        }
        $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());

        $this->_itemCollection->load();

        foreach ($this->_itemCollection as $product) {
            $product->setDoNotUseCategoryId(true);
        }

        // try to get another new collection if related product is not enough
        if ($this->_itemCollection->getSize() < 5) {
            // create new collection
            $collection = $product->getCollection();
            $collection->addAttributeToSort(
                            'created_at',
                            'desc'
                        );
            // want to get 5 product
            $collection->getSelect()->limit(5);
            $collection->load();
            // it show all the product
            error_log($collection->getSize());
        }

        return $this;
    }
}
?>

  I try to use same method to limit the collection and it is fine in
  other custom file like controller, template but It is not work in this
  file. May someone help me to solve or investigate this issue ?


texts: How to get cheapest shipping method selected on get quote

texts:
I have make some change in file to make it selected but i don't think this is the right to make it working like this.so i just want to know from the master that is there any other way to do it using magento standard code

I have rewrite the checkout controller estimatepostaction.

Here is below code.

public function estimatePostAction()
{
    /*
     * if the quantity in the cart is updated, then the estimate address is updated
     * to the changed address
     * if the quantity is not updated, then the estimate address is set to the default
     * one available
     *
     */
    $country = (string) $this->getRequest()->getParam('country_id');
    $postcode = (string) $this->getRequest()->getParam('estimate_postcode');
    $city = (string) $this->getRequest()->getParam('estimate_city');
    $regionId = (string) $this->getRequest()->getParam('region_id');
    $region = (string) $this->getRequest()->getParam('region');

    $quote = $this->_getCart()->getQuote();

    $quote->getShippingAddress()
        ->setCountryId($country)
        ->setPostcode($postcode)
        ->setRegionId($regionId)
        ->setCollectShippingRates(false)
        ->collectShippingRates();
    $this->_getCart()->save();

    $cartShippings = [];
    $allRates = $quote->getShippingAddress()
        ->collectShippingRates()
        ->getGroupedAllShippingRates();
    foreach ($allRates as $carrier) {
        foreach ($carrier as $rate) {
            $cartShippings[] = $rate->getData();
        }
    }

    // This code calculates the lowest shipping amount and the shipping code associated
    // with it.

    $totalShippingMethods = count($cartShippings);
    $minValue = (float) 999999;
    $lowestShipingCode = '';
    for ($smallVal = 0; $smallVal < $totalShippingMethods; $smallVal ++) {
        $current_rate = (float) $cartShippings[$smallVal]['price'];
        if ($current_rate < $minValue) {
            $minValue = $cartShippings[$smallVal]['price'];
            $lowestShipingCode = $cartShippings[$smallVal]['code'];
        }
    }

    $leastShippingCode = (string) $lowestShipingCode;

    // setting the shipping code to the quote.
    if (! empty($leastShippingCode)) {
        $this->_getQuote()
            ->getShippingAddress()
            ->setShippingMethod($leastShippingCode)/*->collectTotals()*/->save();
    }
    $this->_goBack();
}


texts:
When I enter pin code and click on enter button it is not working though its  working on mouse click. How to solve it?

        Zip Code : <input type="text" id="cod" class="product-custom-option" name="cod" value="" placeholder="Enter pincode">
        <button type="button" onclick="checkCOD();" name="zip-check" title="Check" class="button" id="zip-check">Check</button>

My Script as follows :


texts:
I could call web service from block with code below : $jsonObject=json_decode(file_get_contents("http://www.testservice.com:50001/Services/Magento.asmx/getPayer?input=".$datasJson));

How can i call service from java script? I tried with code below, but it's all not work.

urlBuilder.createUrl('http://wsq.starcosmosgroup.com:50001/Services/Magento.asmx/getPayer?input=', {}),
JSON.stringify({
     parameter1: 'data1',
     parameter2: 'data2'
}

UPDATE :

I tried to get the data from service for change the billing address data in checkout page. I adding the code below, and add 'jquery' to the define, but it made the other function error, so how can i get the data from the service?

billing-address.js :

getBill: function (prefix) {
   payload = {
        parameter1: prefix,
        parameter2: 'data'
   };
   url = "http://www.testservice.com:50001/Services/Magento.asmx/getPayer?input="+JSON.stringify(payload);

   alert(url);
   $.get(url, function(response) {
        data = response;
        alert(response);
   });
   return data;
},


texts: Undefined index: type_id - Catalog Search indexer

texts:
Installed Smile-sa elasticSuite for Magento 2.3.3 and when indexing it gives this error:

Catalog Search indexer process unknown error:
Notice: Undefined index: type_id in /srv/html/src/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/PriceData.php on line 64

Debugging that line 64 with a var_dump, i see that the dump looks like this:

    [18458]=>
  array(7) {
    [74]=>
    string(7) "1234566"
    [92]=>
    string(3) "N/A"
    [96]=>
    string(7) "Enabled"
    [122]=>
    string(13) "Taxable Goods"
    [71]=>
    string(4) "test"
    [72]=>
    string(4) "test"
    [73]=>
    string(4) "test"
  }

Now, this is happening on a dev site as a replica of the live site (same data) and with all extensions and themes REMOVED.

Trying the same on a fresh magento install i get this dump:

[1996]=>
  array(9) {
    ["entity_id"]=>
    string(4) "1996"
    ["attribute_set_id"]=>
    string(2) "10"
    ["type_id"]=>
    string(12) "configurable"
    ["sku"]=>
    string(5) "WSH06"
    ["has_options"]=>
    bool(true)
    ["required_options"]=>
    bool(false)
    ["created_at"]=>
    string(19) "2020-04-16 11:36:46"
    ["updated_at"]=>
    string(19) "2020-04-16 11:36:46"
    ["visibility"]=>
    string(1) "4"
  }

Which is correct, and indeed smile-sa ElasticSuite looks for that type_id key, which is missing from the live server data dump.

What could cause this issue on live server?

Do you have any suggestions on what might be the solution here?

Thanks!


texts: get order, customer, product details in observer magento 2

texts:
I am trying to get order,customer,product details in observer. I am using event sales_order_save_after.

<?php
namespace Gworks\Sms\Model\Observer;
use Magento\Framework\Event\ObserverInterface;
class AfterPlaceOrderObserver implements ObserverInterface
{
    protected $_logger;
    public function __construct(
    \Psr\Log\LoggerInterface $logger, //log injection
    array $data = []
    ) {
    $this->_logger = $logger;
       // parent::__construct($data);
    }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
     //order id
     $order = $observer->getEvent()->getOrder();
     $order_id = $order->getIncrementId();
     $this->_logger->info($order_id);

     //product id and name
     foreach($order->getAllItems() as $item)
     {
     $ProdustIds[]= $item->getProductId();
     $proName[] = $item->getName(); // product name
     }
     foreach($proName as $name)
     {
       $this->_logger->info($name);
     }
     foreach($ProdustIds as $id)
     {
       $this->_logger->info($id);
     }

     //customer id
     $customerid = $order->getCustomerId();
     $this->_logger->info($customerid);

     //customer name
     $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
     $customer = $objectManager->create('Magento\Customer\Model\Customer')->load($customer);
     $name=$customer->getName();
     $this->_logger->info($name);
    }
}

I need to get below details.

customer name
phone number
ordered product name
shipping address

I have to collect customer name and product name in system.log but I stuck with get shipping address and phone number in log.


texts: The use of function html_entity_decode is forbidden. What should we use instead?

texts:
Ecg coding standards forbids using html_entity_decode method.

What should we use instead?


texts: New value to dropdown of product attribute is ignored : Magento 2.1

texts:
While uploading new product, if attribute value of dropdown is not mathces with existing dropdown  values then it is getting ignored, it needs manual effort .
What approach should take to achieve it programmatically ?


texts: Store views are changing once we change page

texts:
We are following this link to display store views based on country.

If someone visit site from USA, it will open us store view , Canada => Canada store view, so on.

We are displaying store view switcher on top as here. Someone from USA changed store view to Canada store view.

But once he click on any other page (menu, catalog, Product ,cms) it will again display old (USA) store view.

But it should be in same store view until we change it manually.

Observer.php :

class Atwix_Ipstoreswitcher_Model_Observer
{
    /**
     * redirects customer to store view based on GeoIP
     * @param $event
     */
    public function controllerActionPostdispatch($event)
    {

        if (!empty($_GET['___from_store'])) {
            Mage::app()->setCurrentStore($_GET['___store']);
        } else {
            $geoIP = Mage::getSingleton('geoip/country');
            $cnCode = $geoIP->getCountry();
            // echo $cnCode;
            // echo $cnCode='IN';
            switch ($cnCode) {
                case "US": {
                    Mage::app()->setCurrentStore('usa');
                    break;
                }
                case "IN": {
                    Mage::app()->setCurrentStore('india');
                    break;
                }
                case "CA": {
                    Mage::app()->setCurrentStore('canada');
                    break;
                }
                case "UK": {
                    Mage::app()->setCurrentStore('europe');
                    break;
                }

                case "AU": {
                    Mage::app()->setCurrentStore('australia');
                    break;
                }
            }

        }

    }
}


texts: Stopping redirect cart page from onepage checkout when product is out of stock

texts: When I stay on onepage checkout page and product is out of stock and when I click on next step it is redirecting cart page due to produc is out of stock So I want to stop to redirect cart page.


texts:
I made an order shipment with aymakan shipping I made 5 then number 6 gave me this number 336825
given number should be : AY324007592 like this


texts: Setup version for module 'Namespace_Modulename' is not specified : Magento 2

texts:
I am creating an module in Magento 2 ( ver. 2.0.0). I have registered my module in app/etc/config.xml

'Namespace_Modulename => 1,

My module.xml file under app/code/Namespace/Modulename/etc/module.xml

module.xml :

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
  <module name="Namespace_Modulename" setup_version="2.0.1"/>
</config>

When I run my module Magento 2 generate below error :

  Setup version for module 'Namespace_Modulename' is not specified

My module was working fine before stable release, after upgraded to stable release I start getting this error. I searched lot on google before adding here, got some results but none of then working for me.

Kindly guide me where I am doing wrong.


texts: Solr Bridge on CE, exclude product descriptions

texts:
Using Solr bridge extension on 1.8.1.

I need to exclude product descriptions from being used to generate search results, as it contains text that can confuse the search results.

For example, if the description says "This lamp is designed to stand on a table." then when the phrase "table" is searched for, the lamp appears in the search results, which is not desired behavior in this case.

How would I do this? Can it be done by editing the configuration of the solr installation itself or will it need to be done within the Magento extension?


texts: magento 1.9 Catalog Price rules are not carried over to the shopping cart and checkout?

texts: i'm having troubles with catalog price rules.i have a rule for a catalog product- which appears to look correct on product. Product have many option and difference price. When i add product to cart, the price product is base price, not change with any option i selected before.


texts: How do Magento developers create Magento code?

texts:
This may be a stupid question but I wanted to ask this out of curiosity.

How Magento's developers create whole Magento framework?

If you check Magento 2's vendor/magento folder, you will find more than 35000 files in it. I am just curious. Do Magento's developer team create all these files manually? Do they write each and every line of code by their hands? Or do they have an automated tool like module creator to create modules to further modify as per requirements?

  Feel free to move this question to its respective site if you feel it
  does not belong here.


texts: Error logging into magento admin, magento-1.9

texts:
There has been an error processing your request
SQLSTATE[HY000] [1045] Access denied for user 'dev_bechnus'@'localhost' (using password: YES)

Trace:

0 /home/dev/public_html/lib/Zend/Db/Adapter/Pdo/Mysql.php(109): Zend_Db_Adapter_Pdo_Abstract->_connect()
1 /home/dev/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(320): Zend_Db_Adapter_Pdo_Mysql->_connect()
2 /home/dev/public_html/lib/Zend/Db/Adapter/Abstract.php(460): Varien_Db_Adapter_Pdo_Mysql->_connect()
3 /home/dev/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
4 /home/dev/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
5 /home/dev/public_html/app/code/core/Mage/Core/Model/Resource.php(169): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
6 /home/dev/public_html/app/code/core/Mage/Core/Model/Resource.php(110): Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))
7 /home/dev/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(320): Mage_Core_Model_Resource->getConnection('core_write')
8 /home/dev/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(350): Mage_Core_Model_Resource_Db_Abstract->_getConnection('write')
9 /home/dev/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(335): Mage_Core_Model_Resource_Db_Abstract->_getWriteAdapter()
10 /home/dev/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(360): Mage_Core_Model_Resource_Db_Abstract->_getReadAdapter()
11 /home/dev/public_html/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(134): Mage_Core_Model_Resource_Db_Abstract->getReadConnection()
12 /home/dev/public_html/app/code/core/Mage/Core/Model/Config.php(1348): Mage_Core_Model_Resource_Db_Collection_Abstract->__construct(Object(Mage_Core_Model_Resource_Website))
13 /home/dev/public_html/app/code/core/Mage/Core/Model/Config.php(1380): Mage_Core_Model_Config->getModelInstance('core_resource/w...', Object(Mage_Core_Model_Resource_Website))
14 /home/dev/public_html/app/Mage.php(491): Mage_Core_Model_Config->getResourceModelInstance('core/website_co...', Object(Mage_Core_Model_Resource_Website))
15 /home/dev/public_html/app/code/core/Mage/Core/Model/Abstract.php(208): Mage::getResourceModel('core/website_co...', Object(Mage_Core_Model_Resource_Website))
16 /home/dev/public_html/app/code/core/Mage/Core/Model/Abstract.php(213): Mage_Core_Model_Abstract->getResourceCollection()
17 /home/dev/public_html/app/code/core/Mage/Core/Model/App.php(608): Mage_Core_Model_Abstract->getCollection()
18 /home/dev/public_html/app/code/core/Mage/Core/Model/App.php(466): Mage_Core_Model_App->_initStores()
19 /home/dev/public_html/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Model_App->_initCurrentStore('', 'store')
20 /home/dev/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
21 /home/dev/public_html/index.php(87): Mage::run('', 'store')
22 {main}

Error log record number: 1305294887180


texts: Magento 2 search error when searching using space in between 'Rug test'

texts:
Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 3, query was: SELECT e.*, IF(at_is_active.value_id > 0, at_is_active.value, at_is_active_default.value) AS is_active FROM catalog_category_entity AS e
INNER JOIN catalog_category_entity_int AS at_is_active_default ON (at_is_active_default.entity_id = e.entity_id) AND (at_is_active_default.attribute_id = '46') AND at_is_active_default.store_id = 0
LEFT JOIN catalog_category_entity_int AS at_is_active ON (at_is_active.entity_id = e.entity_id) AND (at_is_active.attribute_id = '46') AND (at_is_active.store_id = 1) WHERE (IF(at_is_active.value_id > 0, at_is_active.value, at_is_active_default.value) = '1') AND (())
Exception #1 (PDOException): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 3

Magento 2.4 elastic search, getting error when searching any product with space in between

For e.g. Rug test


texts:
I don't understand this error because for one it's in my spanish version and it's exactly the same in the english version. Another thing is that the error (below) says it was previously declared at the same place as the error.

PHP Fatal error:  Cannot redeclare isProductSpecial() (previously declared in /home/xxxx/public_html/app/design/frontend/spanish/default/template/catalog/product/view.phtml:203) in /home/xxxx/public_html/app/design/frontend/spanish/default/template/catalog/product/view.phtml on line 203

Here is the code:

        <?php
        function isProductNew($product) {
        $todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
        if($todayDate >= $product->getData('news_from_date') && $todayDate <= $product->getData('news_to_date'))
        {
        return TRUE;
        }
        else
        {
        return FALSE;
        }}
        echo (isProductNew($_product)) ? '

' : '';
        ?>
        <?php
        function isProductSpecial($product) {
        $todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
        if($todayDate >= $product->getData('special_from_date') && $todayDate <= $product->getData('special_to_date'))
        {
        return TRUE;
        }
        else
        {
        return FALSE;
        }}
        echo (isProductSpecial($_product)) ? '

' : '';
        ?>

Any idea how to correct this? Google Webmaster says this is causing many pages to have Index coverage issues.


texts: Problem with cookie vinaikoop jsmessage extesnion

texts:
We are using vinaikoop jsmessage extension to show the success, error message because we have FPC/varnish on our website.

There is issue with this extension, like it save messages inside a cookie which name is jsmessages, so after displaying the mesages it set the value '-' instead of actual value as per code. But it do not like we reload the page it again show the previous messages from the same cookie on page.

so I tried to debug the js code using developer tool but there were a surprise because when I add the breakpoint on the location where we are saving the jsmeesages value to '-', it worked fine. So whenever I used breakpoint into the js code it always works fine.

But when I removed the breakpoint and run the code it create the problem. I used console.log to know the value when we are saving the cookie then nothing find wrong with code.

I am not able to know the reason of issue. Below is the extension js code:-

var JsMessages = Class.create();
JsMessages.prototype = {
    initialize: function(data) {
        this.domain = data.domain;
        this.cookie = data.cookie;
        this.wrapper = '#vinaikopp-jsmessages';
        this.messages = decodeURIComponent(Mage.Cookies.get(this.cookie));
        if (this.messages && this.messages !== '-') {
            var cookie_name = this.cookie; // 'jsmessages'
            [this.domain, '.' + this.domain].each(function(domain) {
                console.log('domain:- ' + domain); // it show domain.com
                console.log('Cookie Path:- ' + Mage.Cookies.path); // path:- '/'
                console.log('Cookie Expiry:- ' + Mage.Cookies.expires);// expiry:- null
                var result = Mage.Cookies.set(cookie_name, '-', Mage.Cookies.expires, Mage.Cookies.path, domain);
                console.log('Cookie set result:- ' + result );
                console.log('Cookie messages:-' + this.messages); // message:- '-'
            });
            document.observe('dom:loaded', this.renderMessages.bind(this));
        }
    },
renderMessages: function()
{
    var type, messages = JSON.parse(this.messages);

    for(type in messages) {
        if (messages.hasOwnProperty(type) && messages[type].length) {
            this.renderMessage(type, messages[type]);
        }
    }
},
renderMessage: function(type, messages)
{
    var container, content = '';
    if (container = this.getMessagesElement(type)) {
        messages.each(function(message) {
            content += "
" + decodeURIComponent(message) + "
\n";
        });
        container.update("
\n" + content + "
")
        container.show();
    }
},
getMessagesElement: function(type)
{
    var elements = $$(this.wrapper + ' .' + type + '-msg');
    if (elements.length) {
        return elements[0];
    }
    return false;
}

}

After successful loading the page when I try to get value

decodeURIComponent(Mage.Cookies.get('jsmessages'));

it show the messages instead of '-'.

I put the console.log inside core magento cookie.js file to know might be there is some code which is saving the same value again but unfortunately didn't find anything.

Please let me know if anyone have the solution.

Here is the plugin github url:- https://github.com/Vinai/VinaiKopp_JsMessages


texts: Magento 2: Add CSS class to ui_component listing table

texts:
I want to add a custom CSS class to the ui_component listing table. The listing table is created as follows:
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">aw_helpdesk2_ticket_frontend_listing.aw_helpdesk2_ticket_frontend_listing_data_source</item>
        </item>
    </argument>
    <settings>
        <spinner>aw_helpdesk2_ticket_columns</spinner>
        <deps>
            <dep>aw_helpdesk2_ticket_frontend_listing.aw_helpdesk2_ticket_frontend_listing_data_source</dep>
        </deps>
    </settings>

I tried adding
<item name="config" xsi:type="array">
    <item name="fieldClass" xsi:type="string">custom-class</item>
</item>

But it is not working


texts: Display number of orders per customer in admin order view

texts:
I'm trying to display number of orders made per customer in admin order grid, using the following join and select I could get the number or orders.
$collection->getSelect()->joinLeft('sales_flat_order', 'main_table.increment_id=sales_flat_order.increment_id','sales_flat_ordercustomer_email');
 $readAdapter = Mage::getSingleton('core/resource')
        ->getConnection('core_read');
     $select = $readAdapter->select()
        ->from('sales_flat_order')
        ->columns(array('orders_count' => new Zend_Db_Expr('COUNT(*)')))
        ->group('sales_flat_order.customer_email');

                $collection->getSelect()
        ->joinLeft(  array('orders_count' => new Zend_Db_Expr('('.$select.')')),  'sales_flat_order.customer_email = orders_count.customer_email',  array('orders_count.orders_count'));
        $collection->addFilterToMap('orders_count', 'orders_count.orders_count');

this is the result >>
increment_id  count_orders  email
1000001       3             customer@customer.com
1000008       3             customer@customer.com
1000015       3             customer@customer.com

how could I get sum of orders at time of every order, not sum of all orders
increment_id  count_orders  email
1000001       1             customer@customer.com
1000008       2             customer@customer.com
1000015       3             customer@customer.com


texts:
Setup: Magento 2.2.x, OpenSouce (Magento Community Edition)

Products were imported from Magento 1,

url_path attributes were cleared
all url_key values are unique (both products & categories)

After 48.0h, some of product url_keys gets nulled (NULL value in catalog_product_entity_varchar), without ANY operations done by the Client.

Has anyone experienced such issue before?


texts: Header Tag How can I change Product wise dynamically?

texts: I want to Change my header title tag product wise dynamically.my Magento version is 2.3.4. how can I get SKU title to set header title tag? I want to solve this problem. I want to Dynamically change title


texts: calculate shipping price and write value in attribute after save product page

texts:
Each product have a addiotinal attribute "shipping_cost".
In magento admin product page i add the product weight in the "weight" attribute.

[weight] * shipping_rate = [shipping_cost]

After i click the product save button i need a function to calculate the shipping cost and write the result in the "shipping_cost" attribute based on the product weight.

For example: If the product weight is 3,20kgs the automated calculation is:

3,20kgs * 6,50 Euro = 20,80 Euro.

The script need to write the result (20,80) in the shipping_cost attribute.

We have diffrent shipping rates:

Up to 1kgs -> 4,90 Euro
From 1kgs to 3kgs -> 5,50 Euro
From 3kgs to  5kgs -> 6,50 Euro
From 5kgs to 10kgs -> 7,90 Euro
From 10kgs to 20kgs -> 10,50 Euro
From 20kgs to 31,50kgs -> 13,90 Euro

Do you have a idea how i can solve this problem?

Similar question i found:
How to add computation on a product attribute in magento admin

Update:
Now i found a solution for press "save" button in the product edit mask.
But this dont run with product mass action under the product grid.
Do you have a idea how i can add a extra entry in the mass dropdown in the product grid?

Update

No i create a solution that only works in the product edit mask if i use the product save button. What i have to change to make my script also run with mass actions from the product grid? How i can create a extra entry in the dropdown for mass action in the product grid and add my script to them?

data.php

<?php
class Wmkosc_Productcost_Helper_Data extends Mage_Core_Helper_Abstract
{
}

config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Wmkosc_Productcost>
      <version>0.1.0</version>
    </Wmkosc_Productcost>
  </modules>
  <global>
    <helpers>
      <productcost>
        <class>Wmkosc_Productcost_Helper</class>
      </productcost>
    </helpers>
    <models>
      <productcost>
        <class>Wmkosc_Productcost_Model</class>
        <resourceModel>productcost_mysql4</resourceModel>
      </productcost>
    </models>
    <events>
      <catalog_product_save_after> <!-- identifier of the event we want to catch -->
        <observers>
          <catalog_product_save_after_handler> <!-- identifier of the event handler -->
            <type>model</type> <!-- class method call type; valid are model, object and singleton -->
            <class>productcost/observer</class> <!-- observers class alias -->
            <method>updateShippingCost</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to observer -->
          </catalog_product_save_after_handler>
        </observers>
      </catalog_product_save_after>
    </events>
  </global>
</config>

observer.php:

<?php
class Wmkosc_Productcost_Model_Observer{
    public function updateShippingCost(Varien_Event_Observer $observer){
        $_pro = $observer->getProduct();
        $weight = $_pro->getWeight();
        if($weight < 1){
            $shipcost = '4.9';
        } elseif($weight < 3){
            $shipcost = '5.5';
        } elseif($weight < 5){
            $shipcost = '6.5';
        } elseif($weight < 10){
            $shipcost = '7.9';
        } elseif($weight < 20){
            $shipcost = '10.5';
        } elseif($weight < 31.5){
            $shipcost = '13.9';
        } else{
            $shipcost = '';
        }
        $_product = Mage::getModel('catalog/product')->load($_pro->getId());
        $_product->setData('versandkosten_de',$shipcost);
        $_product->getResource()->saveAttribute($_product,'versandkosten_de');
    }
}


texts: How to handle payment through Paypal without collecting the shipping infromation?

texts:
The store that I am working on is a Pick-up store, which means that customers can order the things on-line but collection of orders has to be done from the store itself; the customers have to go to the store to collect order items.

Hence, there is nothing like shipping for this online store. So we donot collect shipping information from the user during registration as instructed by the client.

Now at the same time, the client insists to use Paypal Express Checkout for the payment.

Which means that if the user is registered but his shipping information is not available, and if he tries to checkout, the following error appears :

"PayPal gateway has rejected request. The field Shipping Address1 is required (#10727: Shipping Address1 Empty). The field Shipping Address City is required (#10728: Shipping Address City Empty)."

Is there anyway to handle the situation??

I mean, can I do something so that the above fields for Paypal do not remain compulsory or else pass some random static value for them along with other parameters to Paypal?

Any help would be appreciated.

Thanks in advance


texts: Fix error "There was a problem with reindexing process." or "Cannot initialize the indexer process."

texts:
I am having an issue reindexing my content in Magento. Both Product Flat Data and Product Category Data need to be re-indexed and it won't index for me.

I have tried deleting all content in /var/locks and /var/reports. I have also tried truncating/deleting the "mg_catalog_product_flat_1" table to no avail. When I check the logs it looks like the table still exists. In phpMyAdmin, the table is listed in the left hand structure but when I click it I see the below error:

In the admin panel I've received both "There was a problem with reindexing process."  and "Cannot initialize the indexer process.". I've also tried to reindex manually via SSH and I get the same errors. Under SSH, all of the other indexes succeed except the Product Flat Data and Product Category.

Since the table doesn't exist I'm not sure why my exception.log shows the following (Note: hashtags/pound symbol beforeline numbers has been omitted and extra line spaces have been added for clarity):

  2014-08-04T19:23:39+00:00 DEBUG (7): Exception message: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mg_catalog_product_flat_1' already exists

  Trace: 0 /home/waterwal/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

  1 /home/waterwal/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)

  2 /home/waterwal/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)

  3 /home/waterwal/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('CREATE TABLE `m...', Array)

  4 /home/waterwal/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('CREATE TABLE `m...', Array)

  5 /home/waterwal/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(2117): Varien_Db_Adapter_Pdo_Mysql->query('CREATE TABLE `m...')

  6 /home/waterwal/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(701): Varien_Db_Adapter_Pdo_Mysql->createTable(Object(Varien_Db_Ddl_Table))

  7 /home/waterwal/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1389): Mage_Catalog_Model_Resource_Product_Flat_Indexer->prepareFlatTable(1)

  8 /home/waterwal/public_html/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_Indexer->reindexAll()

  9 /home/waterwal/public_html/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(350): Mage_Catalog_Model_Product_Flat_Indexer->reindexAll()

  10 /home/waterwal/public_html/app/code/core/Mage/Index/Model/Process.php(210): Mage_Catalog_Model_Product_Indexer_Flat->reindexAll()

  11 /home/waterwal/public_html/app/code/core/Mage/Index/Model/Process.php(258): Mage_Index_Model_Process->reindexAll()

  12 /home/waterwal/public_html/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php(182): Mage_Index_Model_Process->reindexEverything()

  13 /home/waterwal/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Index_Adminhtml_ProcessController->massReindexAction()

  14 /home/waterwal/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('massReindex')

  15 /home/waterwal/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))

  16 /home/waterwal/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()

  17 /home/waterwal/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)

  18 /home/waterwal/public_html/index.php(87): Mage::run('', 'store')

  19 {main}

If anyone has any suggestions I will definitely try them, I really need to get this fixed! Thanks!


texts: Show "View as" in toolbar before grid and list modes

texts:
I want to show "View as" in toolbar just before grid and list modes.

I found its already exist in template file but is hidden:

  vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/viewmode.phtml

 <?= /* @escapeNotVerified */ __('View as') ?>

and in

  vendor/magento/theme-frontend-blank/Magento_Catalog/web/css/source/module/_toolbar.less
  _toolbar.less

.modes-label {
    &:extend(.abs-visually-hidden-desktop all);
}


texts: Error when exporting products: Type Error occurred when creating object: Magento\Framework\MessageQueue\PublisherPool

texts:
I'm getting this error when trying to export products:

  Exception #0 (BadMethodCallException): Missing required argument $publishers of Magento\Framework\MessageQueue\PublisherPool.

From exception.log

[2020-04-30 19:28:31] main.CRITICAL: Type Error occurred when creating object: Magento\Framework\MessageQueue\PublisherPool {"report_id":"28a0645effcf33b263b1cc45ebf94987ba9754b7bcb411fbf478c2e235cb0068","exception":"[object] (Magento\Framework\Exception\RuntimeException(code: 0): Type Error occurred when creating object: Magento\Framework\MessageQueue\PublisherPool at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:131)"} []

Any ideas? Thanks


texts: Why category ids filter doesn't work on product export?

texts:
In Magento v2.0.4 Admin Panel go to System > Data Transfer > Export then select Entity Type: Products.

At that point the filtering grid appears.

The first option is Categories corresponding to category_ids product attribute; the text field brings us to think we can filter on it, maybe specifying the comma-separated list of category IDs.

But it doesn't work.

Why?


texts: Magento 2 product import problem on windows 7

texts: I have tried product import with images on windows 7 using CSV file. It shows error "Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s)". I have set all permission on folders. May I know import products with images on windows 7 is possible?


texts: How can Enable Product (a [website] scope property) can have different values in one specific store view vs All Store?

texts:
I have 1 website, 1 store and 2 store views (for English and Finnish languages.),
If "Enable product" scope is website. Then how come it can have different values between these Scope: Default vs All Store Views.
I was expecting that updating one of them updates the other. This is what is happening between default vs Finnish store views. Updating one of them affects the other. But between all store views and each store view updating one of them does not affect the other. I can also ask why even we have Use default value option available if sth has scope of website.

Just switching to


texts: How to add new option field in attribute value list

texts:
I am trying to add new attribute value option, I have read many articles but still I can't achieve what I want, please any idea.

In the attached page you will see a new field I called it description, I need this field to be saved for every option value in my magento database.

Please note that I have used magento 1.9.2.4

Thank you in advance


texts:
I am trying to send an email when order is canceled. I followed this tutorial:

  http://www.atwix.com/magento/emails-for-custom-events/

Here is my code i need help setting it up becouse now it is not working:

Local.xml:

              1.0.0

<global>
    <models>
        <cancelemail>
            <class>Ylli_Cancelemail_Model</class>
        </cancelemail>
    </models>
    <events>
        <sales_order_save_commit_after>
            <observers>
                <Ylli_Cancelemail_Model_Observer>
                    <type>singleton</type>
                    <class>Ylli_Cancelemail_Model_Observer</class>
                    <method>invoicedStatusChange</method>
                </Ylli_Cancelemail_Model_Observer>
            </observers>
        </sales_order_save_commit_after>
    </events>
    <template>
        <email>
            <custom_order_tpl module="Ylli_Cancelemail">
                <label>Status Mail Invoice</label>
                <file>statusmail_canceled.html</file>
                <type>html</type>
            </custom_order_tpl>
        </email>
    </template>
</global>

Observer.php

class Ylli_Cancelemail_Model_Observer {
    public function invoicedStatusChange($event)
    {
        $order = $event->getOrder();
        var_dump($order);
        Mage::log('worked', null, 'cancelemail.log');
        $orderStatus = $order->getStatus();
        if ($order->getState() == Mage_Sales_Model_Order::STATE_CANCELED)
            $this->_sendStatusMail($order);
    }

private  function _sendStatusMail($order)
{
    $emailTemplate  = Mage::getModel('core/email_template');

    $emailTemplate->loadDefault('custom_order_tpl');
    $emailTemplate->setTemplateSubject('Your order was holded');

    // Get General email address (Admin->Configuration->General->Store Email Addresses)
    $salesData['email'] = Mage::getStoreConfig('trans_email/ident_general/email');
    $salesData['name'] = Mage::getStoreConfig('trans_email/ident_general/name');

    $emailTemplate->setSenderName($salesData['name']);
    $emailTemplate->setSenderEmail($salesData['email']);

    $emailTemplateVariables['username']  = $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname();
    $emailTemplateVariables['order_id'] = $order->getIncrementId();
    $emailTemplateVariables['store_name'] = $order->getStoreName();
    $emailTemplateVariables['store_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
    $emailTemplate->send($order->getCustomerEmail(), $order->getStoreName(), $emailTemplateVariables);
}

Any help is appreciated. thanks in advace


texts: Magento 1.9 COD custom maximum order value & minimum order value limit set

texts:
I was disabled default COD module. Now I am using CashOnDelivery Based on Zipcode from magentocommerce. I need to add two custom fields Minimum order total & Maximum order total in backend. Through xml I was added those fields here the screen.  Now I need to process the condition minimum & maximum order total.

Here my CashOnDelivery Based on Zipcode module code.`

public function getCashOnDelvery(Varien_Event_Observer $observer) {
        $event           = $observer->getEvent();
        $method          = $event->getMethodInstance();
        $result          = $event->getResult();
        $isModuleEnable = Mage::getStoreConfig('cod/cod/enable');

        if($isModuleEnable) {

            if($method->getCode() == 'cashondelivery' ){

                $quote = Mage::getSingleton('checkout/cart')->getQuote();
                $add = $quote->getShippingAddress();
                $postcode = $add->getData('postcode');

                $comparisonMode = Mage::getStoreConfig('cod/cod/mode');
                $zipCodes = Mage::getStoreConfig('cod/cod/zipcode');
                $isExist = false;

                if(trim($zipCodes) == '') {
                    $result->isAvailable = true;
                } else {

                    if(strpos($zipCodes, $postcode) !==  false) {
                        $isExist = true;
                    }

                    if($isExist != true) {

                        $zipCodesArray = explode(',', nl2br($zipCodes));
                        if(count($elementLineArray) > 1) {
                            foreach($zipCodesArray as $codzipLine) {
                                $elementLineArray = explode('-', $codzipLine);
                                if(count($elementLineArray) == 2 && ( $postcode >= $elementLineArray[0] && $postcode <= $elementLineArray[1] )) {
                                    $isExist = true;
                                    break;
                                } else if($postcode == $codzipLine) {
                                    $isExist = true;
                                    break;
                                }
                            }
                        }
                    }

                    $returnValue = '';
                        $returnValue = ($isExist)?true:false;

                    $result->isAvailable = $returnValue;

                }

            }
        }
    }
}

`
Dear Magento Experts can you help me to solve this?


texts: What is the correct way to set up a store/store views?

texts:
I am new to Magento and am after some rather initial guidance.

Firstly, what is the correct way to set up stores / store views? Should it be as per option one or two below?

Option 1

>WEBSITE
>>Australia [AUD]
>>>English

>>United States [USD]
>>>English

>>Europe [EUR]
>>>English
>>>French
>>>Spanish
>>>Greek

Option 2

>WEBSITE
>>STORE
>>>Australia [AUD]
>>>United States [USD]
>>>Europe [EUR]