Magento : MySQL server crash when “Copying to tmp table” process runs - php
We have around 8k products in our Magento store. The following query starts every 5 minutes and does not seem end. I have checked process chart and found this query running many times. When MySQL reaches to its allowed connection (200 Concurrent Connections are allowed), it is crashed. This is happening in every hour and we have to restart the MySQL server.
I googled and didn't get any solution.
SELECT`e`.* , IF( at_status.value_id >0, at_status.value, at_status_default.value )AS`status` , IF( at_visibility.value_id >0, at_visibility.value, at_visibility_default.value )AS`visibility` ,`at_price`.`value`AS`price` ,`stock`.`qty` ,`stock`.`is_in_stock` ,`stock`.`manage_stock` ,`stock`.`use_config_manage_stock` ,`url`.`request_path` ,`categories`.* , GROUP_CONCAT( categories_index.category_id )AS`categories_ids` ,`price_index`.`min_price` ,`price_index`.`max_price` ,`price_index`.`tier_price` ,`price_index`.`final_price`
FROM`catalog_product_entity`AS`e`
INNERJOIN`catalog_product_website`AS`product_website`ON product_website.product_id = e.entity_id
AND product_website.website_id =\'2\'
INNERJOIN`catalog_product_entity_int`AS`at_status_default`ON (`at_status_default`.`entity_id`=`e`.`entity_id`)
AND (
`at_status_default`.`attribute_id`=\'87\'
)
AND`at_status_default`.`store_id`=0
LEFTJOIN`catalog_product_entity_int`AS`at_status`ON (`at_status`.`entity_id`=`e`.`entity_id`)
AND (
`at_status`.`attribute_id`=\'87\'
)
AND (
`at_status`.`store_id`=2
)
INNERJOIN`catalog_product_entity_int`AS`at_visibility_default`ON (`at_visibility_default`.`entity_id`=`e`.`entity_id`)
AND (
`at_visibility_default`.`attribute_id`=\'93\'
)
AND`at_visibility_default`.`store_id`=0
LEFTJOIN`catalog_product_entity_int`AS`at_visibility`ON (`at_visibility`.`entity_id`=`e`.`entity_id`)
AND (
`at_visibility`.`attribute_id`=\'93\'
)
AND (
`at_visibility`.`store_id`=2
)
INNERJOIN`catalog_product_entity_decimal`AS`at_price`ON (`at_price`.`entity_id`=`e`.`entity_id`)
AND (
`at_price`.`attribute_id`=\'67\'
)
AND (
`at_price`.`store_id`=0
)
LEFTJOIN`cataloginventory_stock_item`AS`stock`ON stock.product_id = e.entity_id
LEFTJOIN`core_url_rewrite`AS`url`ON url.product_id = e.entity_id
AND url.category_id ISNULL
AND is_system =1
AND ISNULL( options )
AND url.store_id =2
LEFTJOIN`catalog_category_product`AS`categories`ON categories.product_id = e.entity_id
INNERJOIN`catalog_category_product_index`AS`categories_index`ON categories_index.category_id = categories.category_id
AND categories_index.product_id = categories.product_id
AND categories_index.store_id =2
AND categories_index.category_id
IN ( 3, 298, 299, 300, 301, 302, 306, 462, 463, 464, 465, 466, 467, 468, 469, 470, 303, 434, 435, 436, 441, 442, 443, 444, 445, 446, 304, 305, 480, 481, 482, 307, 309, 310, 311, 474, 313, 447, 448, 449, 418, 312, 419, 479, 314, 405, 406, 407, 408, 409, 315, 428, 438, 316, 415, 416, 417, 317, 402, 403, 404, 384, 385, 387, 388, 389, 390, 391, 430, 437, 439, 440, 308, 378, 379, 380, 381, 382, 458, 459, 383, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 450, 451, 497, 452, 454, 455, 456, 457, 460, 461, 318, 319, 420, 421, 422, 423, 320, 424, 425, 426, 427, 321, 322, 323, 364, 365, 366, 367, 473, 487, 488, 489, 490, 491, 492, 483, 484, 485, 486, 324, 325, 369, 370, 326, 453, 327, 328, 371, 372, 329, 376, 377, 330, 373, 374, 331, 332, 333, 334, 471, 335, 375, 337, 338, 336, 431, 432, 433, 339, 340, 341, 496, 342, 343, 344, 345, 346, 347, 348, 493, 495, 498, 499, 500, 502, 503, 349, 350, 351, 494, 501, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 410, 411, 412, 413, 414, 368, 475, 477, 478)
LEFTJOIN`catalog_product_index_price`AS`price_index`ON price_index.entity_id = e.entity_id
AND customer_group_id =0
AND price_index.website_id =2
WHERE (
IF( at_status.value_id >0, at_status.value, at_status_default.value )=\'1\'
)
AND (
`e`.`type_id`
IN (
\'simple\',\'configurable\',\'bundle\',\'grouped\',\'virtual\',\'downloadable\'
))
AND (
IF( at_visibility.value_id >0, at_visibility.value, at_visibility_default.value )
IN (
\'2\',\'3\',\'4\'
))
AND (
at_price.value >\'0\'
)
AND (
(
is_in_stock !=\'0\'
OR (
manage_stock !=\'1\'
AND use_config_manage_stock !=\'1\'
)
OR (
use_config_manage_stock !=\'0\'
AND 1=0
AND is_in_stock =0
)))
GROUPBY`e`.`entity_id` , `e`.`entity_id`
LIMIT 1500
Related
SQL Error Code error: 42S22. why am I getting this error on the page error code 500. Laravel FWC
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'country_code' in 'where clause' (SQL: select posts.*, categories.parent_id as laravel_through_key from posts inner join categories on categories.id = posts.category_id where categories.parent_id = 200 and country_code = EN and category_id in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 133, 134, 135, 136, 137, 138, 139, 140, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 286, 287, 288, 289, 290, 291, 292, 293, 460, 461, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 595, 596, 597, 598, 599, 600, 601, 602, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 677, 678, 679, 680, 681, 682) and verified_email = 1 and verified_phone = 1) enter image description here when adding another country {"success":false,"message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'country_code' in 'where clause' (SQL: select * from `posts` where `country_code` = enter image description here when SQLSTATE[42S22]: Column not found: 1054 Unknown column 'a.country_code' in 'where clause' (SQL: SELECT sc.id, c.parent_id, count(*) as total FROM posts as a INNER JOIN categories as sc ON sc.id=a.category_id AND sc.active=1 INNER JOIN categories as c ON c.id=sc.parent_id AND c.active=1 WHERE a.country_code = :countryCode AND (a.verified_email=1 AND a.verified_phone=1) AND a.archived!=1 AND a.deleted_at IS NULL GROUP BY sc.id)
Please check your database table named 'posts' and confirm if a column named 'country_code' is present. If 'country_code' is present, then consider changing WHERE a.country_code = :countryCode to WHERE a.country_code = '$countryCode'. Note that I removed ':' from ':countryCode' and I replaced it with '$' in '$countryCode', with the assumption that you have a variable named $countryCode in your code.
Could you share more information about your data structure. That errors mean your column country_code does not exist
Perlin noise implemented in php, undefined offset in permutation table, but index is defined
So, I decided to write a perlin noise implementation in php. Don't ask me why, I've forgotten. Following this: https://flafla2.github.io/2014/08/09/perlinnoise.html , I have gotten to the point where I should be getting some results. Octaves haven't been worked in yet, but the vectors should be doing their thing. Offending code at the bottom of the post. I had a few mistakes when implementing it as a class (seriously, whose idea was it to make it compulsory to preface every in-class variable with a $this->? It almost gave me a literal headache fixing all the mistakes I'd made), but I think I have caught them all. I did have some trouble doubling my permutation matrix, but that is done as well. I know this because I have printed it. However, when I try to get the hash thing, I get a page-full of PHP Notice: Undefined offset: 1 in perlin.php (0 as well as 1). This leads to a bunch of variables that should be integers being null. I have tol my functions what to expect, so I get PHP Fatal error: Uncaught TypeError: Argument 1 passed to perlin::grad() must be of the type int, null given, called in perlin.php on line 56 and defined in perlin.php:73 The thing that confuses me the most is that the array that is complaining is defined all the way from 0 to 511 (inclusive). Am I missing some vital information, like the difference between an index and an offset? Code: <?php class perlin{ public function __construct(){ $p=array_merge($this->permutation,$this->permutation); print_r($p); } private $permutation=array(111, 176, 195, 194, 99, 88, 206, 7, 84, 2, 246, 181, 221, 69, 249, 3, 47, 223, 154, 26, 65, 142, 178, 100, 128, 134, 254, 94, 78, 204, 59, 98, 48, 171, 80, 125, 190, 86, 225, 138, 57, 144, 16, 143, 169, 162, 139, 252, 147, 182, 67, 179, 220, 160, 81, 96, 132, 82, 148, 72, 64, 242, 255, 137, 74, 185, 212, 19, 218, 256, 101, 130, 39, 234, 41, 115, 228, 230, 214, 45, 107, 251, 117, 91, 68, 49, 37, 208, 207, 192, 168, 232, 133, 23, 54, 106, 153, 247, 87, 200, 34, 187, 25, 124, 17, 114, 245, 248, 157, 77, 9, 219, 120, 236, 183, 79, 50, 42, 250, 189, 102, 227, 243, 83, 159, 62, 156, 151, 75, 13, 177, 158, 253, 196, 166, 103, 118, 32, 229, 235, 170, 15, 108, 58, 21, 73, 31, 70, 89, 203, 46, 205, 110, 150, 113, 43, 199, 29, 193, 40, 1, 60, 152, 6, 104, 129, 175, 36, 8, 222, 135, 85, 198, 123, 149, 238, 231, 164, 63, 76, 38, 20, 184, 188, 4, 12, 119, 14, 240, 105, 30, 210, 27, 241, 224, 239, 10, 66, 116, 167, 56, 140, 95, 126, 217, 92, 51, 55, 213, 155, 201, 161, 244, 197, 180, 71, 44, 215, 172, 18, 165, 35, 131, 186, 202, 22, 24, 121, 226, 33, 93, 163, 211, 191, 61, 53, 28, 136, 216, 122, 237, 173, 112, 209, 97, 145, 233, 146, 174, 141, 5, 52, 11, 109, 127, 90); //generated by seq 1 256|shuf|sed 's/$/,/g'|tr '\n' ' ' public $repeat=0; private $p=array(); private function inc($num){ $num++; if($this->repeat>0){ $num%=$this->repeat; } return $num; } private function fade(float $t){ return $t*$t*$t*($t*($t*6+15)+10); } public function perlin(float $x,float $y,float $z){ if($this->repeat>0){ $x=$x%$this->repeat; $y=$y%$this->repeat; $z=$z%$this->repeat; } $xi=(int)($x) & 255; $yi=(int)($y) & 255; $zi=(int)($z) & 255; $xf=$x-(int)($x); $yf=$y-(int)($y); $zf=$z-(int)($z); echo "$xi $yi $zi $xf $yf $zf<br>\n\n"; $u=$this->fade($xf); $v=$this->fade($yf); $w=$this->fade($zf); $aaa=$this->p[$this->p[$this->p[ $xi ]+ $yi ]+ $zi ]; $aba=$this->p[$this->p[$this->p[ $xi ]+$this->inc($yi)]+ $zi ]; $aab=$this->p[$this->p[$this->p[ $xi ]+ $yi ]+$this->inc($zi)]; $abb=$this->p[$this->p[$this->p[ $xi ]+$this->inc($yi)]+$this->inc($zi)]; $baa=$this->p[$this->p[$this->p[$this->inc($xi)]+ $yi ]+ $zi ]; $bba=$this->p[$this->p[$this->p[$this->inc($xi)]+$this->inc($yi)]+ $zi ]; $bab=$this->p[$this->p[$this->p[$this->inc($xi)]+ $yi ]+$this->inc($zi)]; $bbb=$this->p[$this->p[$this->p[$this->inc($xi)]+$this->inc($yi)]+$this->inc($zi)]; $x1=$this->lerp($this->grad($aaa,$xf,$yf,$zf), $this->grad($baa,$xf-1,$yf,$zf),$u); $x2=$this->lerp($this->grad($aba,$xf,$yf-1,$zf), $this->grad($bba,$xf-1,$yf-1,$zf),$u); $y1=$this->lerp($x1,$x2,v); $x1=$this->lerp($this->grad($aab,$xf,$yf,$zf-1), $this->grad($bab,$xf-1,$yf,$zf-1),$u); $x2=$this->lerp($this->grad($abb,$xf,$yf-1,$zf-1), $this->grad($bbb,$xf-1,$yf-1,$zf-1),$u); $y2=$this->lerp($x1,$x2,v); return ($this->lerp($y1,$y2,w)+1)/2; } private function grad(int $hash,float $x,float $y,float $z){ switch($hash & 0xF){ case 0x0: return $x+$y; case 0x1: return -$x + $y; case 0x2: return $x - $y; case 0x3: return -$x - $y; case 0x4: return $x + $z; case 0x5: return -$x + $z; case 0x6: return $x - $z; case 0x7: return -$x - $z; case 0x8: return $y + $z; case 0x9: return -$y + $z; case 0xA: return $y - $z; case 0xB: return -$y - $z; case 0xC: return $y + $x; case 0xD: return -$y + $z; case 0xE: return $y - $x; case 0xF: return -$y - $z; default: return 0; } } private function lerp(float $a,float $b,float $x){ return $a+$x*($b-$a); } } ?>
Convert map area HTML to PDF in PHP (is that possible?)
I would like to know if it is possible to convert an image with map area HTML to PDF in PHP. With TCPDF, including image is not a problem and then drawing forms. But it's almost impossible to draw perfectly every area on my image. <img src="body.jpg" class="img-fluid" id="map-image" style="width: 280px; max-width: 280px; height: auto;" alt="" usemap="#map" /> <map id="map" name="map"> <area href="#" part="MD" data-part="Main Droite" shape="poly" coords="324, 406, 356, 396, 357, 403, 363, 406, 368, 410, 374, 415, 378, 419, 381, 424, 385, 427, 389, 434, 392, 439, 391, 444, 386, 447, 381, 447, 378, 444, 377, 451, 376, 464, 376, 477, 377, 485, 375, 491, 369, 493, 367, 497, 365, 500, 358, 498, 356, 496, 351, 496, 347, 494, 345, 487, 342, 489, 335, 490, 332, 485, 331, 473, 329, 459, 325, 449, 325, 434, 325, 418" /> <area href="#" part="MG" data-part="Main Gauche" shape="poly" coords="45, 401, 79, 410, 79, 422, 79, 436, 79, 446, 77, 460, 75, 473, 72, 482, 70, 488, 65, 490, 61, 487, 59, 482, 56, 491, 55, 497, 52, 498, 47, 497, 45, 500, 41, 502, 37, 500, 35, 497, 35, 492, 31, 491, 28, 488, 28, 484, 28, 478, 28, 468, 28, 456, 28, 450, 28, 444, 22, 444, 14, 446, 12, 443, 11, 437, 14, 434, 17, 429, 23, 423, 28, 420, 35, 413, 42, 407" /> <area href="#" part="MI" data-part="Membres inférieurs" shape="poly" coords="131, 363, 146, 366, 168, 369, 196, 371, 223, 371, 248, 366, 265, 363, 270, 359, 278, 382, 283, 405, 287, 423, 291, 438, 291, 463, 291, 479, 290, 493, 289, 507, 287, 527, 284, 540, 282, 548, 283, 559, 286, 570, 287, 582, 286, 595, 284, 605, 288, 619, 289, 632, 289, 644, 290, 658, 286, 670, 284, 683, 279, 695, 279, 707, 275, 719, 273, 732, 271, 743, 271, 754, 271, 767, 273, 777, 277, 784, 281, 789, 287, 797, 288, 803, 288, 811, 287, 814, 283, 819, 279, 821, 275, 823, 271, 824, 268, 826, 264, 825, 260, 823, 257, 825, 251, 825, 246, 824, 241, 818, 238, 809, 238, 797, 238, 789, 237, 778, 237, 767, 237, 763, 234, 758, 234, 753, 236, 744, 239, 741, 243, 737, 243, 724, 244, 717, 241, 702, 238, 688, 236, 682, 235, 669, 234, 658, 234, 647, 234, 638, 235, 626, 237, 613, 237, 607, 234, 598, 231, 593, 229, 583, 229, 576, 229, 571, 227, 564, 225, 558, 223, 549, 223, 540, 222, 530, 220, 522, 218, 516, 212, 502, 210, 490, 209, 484, 207, 475, 206, 464, 206, 455, 202, 452, 198, 452, 199, 461, 198, 475, 196, 487, 193, 497, 191, 505, 188, 515, 187, 520, 184, 528, 183, 534, 182, 541, 180, 549, 179, 555, 177, 560, 175, 566, 175, 574, 175, 580, 173, 590, 171, 597, 167, 606, 167, 613, 168, 623, 170, 635, 170, 638, 171, 644, 169, 654, 169, 668, 168, 679, 165, 691, 161, 703, 162, 710, 162, 723, 162, 731, 163, 737, 165, 743, 169, 750, 172, 755, 169, 762, 169, 774, 168, 784, 168, 789, 167, 802, 167, 807, 164, 815, 163, 818, 159, 825, 157, 825, 150, 825, 149, 825, 145, 825, 143, 823, 140, 824, 139, 824, 135, 824, 131, 824, 127, 821, 120, 818, 118, 816, 116, 812, 115, 804, 115, 797, 119, 792, 126, 782, 130, 776, 134, 768, 133, 762, 132, 748, 132, 737, 130, 723, 129, 716, 128, 707, 124, 695, 123, 685, 120, 677, 117, 664, 116, 658, 114, 646, 114, 640, 115, 631, 117, 615, 119, 604, 118, 586, 119, 570, 120, 558, 123, 546, 120, 534, 116, 514, 115, 502, 112, 484, 112, 475, 112, 472, 113, 458, 113, 442, 114, 428, 117, 416, 121, 401, 125, 389, 131, 375" /> <area href="#" part="D" data-part="Dos" shape="poly" coords="132, 359, 153, 363, 172, 366, 191, 367, 211, 368, 232, 366, 251, 362, 263, 359, 269, 353, 270, 341, 270, 330, 268, 321, 266, 307, 268, 298, 273, 285, 278, 274, 277, 259, 276, 247, 275, 239, 275, 231, 275, 223, 274, 213, 274, 196, 274, 185, 273, 174, 272, 163, 271, 152, 270, 143, 259, 139, 250, 136, 243, 133, 230, 139, 218, 141, 210, 142, 179, 141, 171, 139, 163, 136, 157, 133, 147, 138, 139, 141, 134, 143, 133, 152, 132, 170, 132, 177, 131, 199, 131, 211, 130, 225, 130, 236, 128, 247, 128, 259, 127, 268, 127, 277, 130, 286, 134, 293, 136, 302, 135, 312, 134, 324, 134, 336, 133, 347" /> <area href="#" part="C" data-part="Cou" shape="poly" coords="167, 94, 173, 97, 181, 103, 190, 110, 202, 114, 213, 111, 222, 106, 229, 97, 234, 96, 233, 104, 233, 116, 234, 124, 236, 129, 239, 131, 232, 136, 222, 138, 211, 139, 201, 139, 193, 139, 182, 139, 173, 137, 167, 134, 161, 131, 161, 130, 167, 127, 170, 124, 170, 117, 170, 111, 169, 105, 168, 100" /> <area href="#" part="MSD" data-part="Membre supérieur Droit" shape="poly" coords="273, 144, 288, 147, 297, 151, 306, 155, 312, 165, 318, 183, 322, 195, 324, 210, 322, 221, 325, 231, 328, 245, 327, 255, 330, 267, 333, 279, 336, 289, 341, 309, 345, 325, 348, 344, 348, 360, 352, 375, 356, 391, 322, 402, 318, 393, 313, 381, 307, 372, 301, 359, 296, 351, 293, 340, 291, 329, 289, 314, 287, 295, 285, 286, 282, 276, 279, 266" /> <area href="#" part="MSG" data-part="Membre supérieur Gauche" shape="poly" coords="125, 268, 119, 284, 116, 299, 112, 322, 112, 333, 108, 345, 101, 357, 95, 375, 84, 394, 79, 404, 48, 395, 53, 368, 54, 356, 58, 331, 60, 316, 63, 302, 66, 290, 72, 280, 73, 264, 76, 251, 80, 231, 82, 222, 83, 213, 82, 192, 83, 186, 87, 177, 92, 163, 101, 155, 111, 149, 123, 145, 131, 144" /> </map> If possible, I want to draw these areas into PDF with some colors etc... Thank you EDIT: Atleast, something to convert html map area (with ImageMapster) into PNG or JPEG image ?
AFAIK, You can direclty use your area from html to TCPDF. First get your areas from html like : // your areas $area[0] = "<area href=\"#\" part=\"MD\" data-part=\"Main Droite\" shape=\"poly\" coords=\"324, 406, 356, 396, 357, 403, 363, 406, 368, 410, 374, 415, 378, 419, 381, 424, 385, 427, 389, 434, 392, 439, 391, 444, 386, 447, 381, 447, 378, 444, 377, 451, 376, 464, 376, 477, 377, 485, 375, 491, 369, 493, 367, 497, 365, 500, 358, 498, 356, 496, 351, 496, 347, 494, 345, 487, 342, 489, 335, 490, 332, 485, 331, 473, 329, 459, 325, 449, 325, 434, 325, 418\" />"; $area[1] = "<area href=\"#\" part=\"MG\" data-part=\"Main Gauche\" shape=\"poly\" coords=\"45, 401, 79, 410, 79, 422, 79, 436, 79, 446, 77, 460, 75, 473, 72, 482, 70, 488, 65, 490, 61, 487, 59, 482, 56, 491, 55, 497, 52, 498, 47, 497, 45, 500, 41, 502, 37, 500, 35, 497, 35, 492, 31, 491, 28, 488, 28, 484, 28, 478, 28, 468, 28, 456, 28, 450, 28, 444, 22, 444, 14, 446, 12, 443, 11, 437, 14, 434, 17, 429, 23, 423, 28, 420, 35, 413, 42, 407\" />"; $area[2] = "<area href=\"#\" part=\"MI\" data-part=\"Membres inférieurs\" shape=\"poly\" coords=\"131, 363, 146, 366, 168, 369, 196, 371, 223, 371, 248, 366, 265, 363, 270, 359, 278, 382, 283, 405, 287, 423, 291, 438, 291, 463, 291, 479, 290, 493, 289, 507, 287, 527, 284, 540, 282, 548, 283, 559, 286, 570, 287, 582, 286, 595, 284, 605, 288, 619, 289, 632, 289, 644, 290, 658, 286, 670, 284, 683, 279, 695, 279, 707, 275, 719, 273, 732, 271, 743, 271, 754, 271, 767, 273, 777, 277, 784, 281, 789, 287, 797, 288, 803, 288, 811, 287, 814, 283, 819, 279, 821, 275, 823, 271, 824, 268, 826, 264, 825, 260, 823, 257, 825, 251, 825, 246, 824, 241, 818, 238, 809, 238, 797, 238, 789, 237, 778, 237, 767, 237, 763, 234, 758, 234, 753, 236, 744, 239, 741, 243, 737, 243, 724, 244, 717, 241, 702, 238, 688, 236, 682, 235, 669, 234, 658, 234, 647, 234, 638, 235, 626, 237, 613, 237, 607, 234, 598, 231, 593, 229, 583, 229, 576, 229, 571, 227, 564, 225, 558, 223, 549, 223, 540, 222, 530, 220, 522, 218, 516, 212, 502, 210, 490, 209, 484, 207, 475, 206, 464, 206, 455, 202, 452, 198, 452, 199, 461, 198, 475, 196, 487, 193, 497, 191, 505, 188, 515, 187, 520, 184, 528, 183, 534, 182, 541, 180, 549, 179, 555, 177, 560, 175, 566, 175, 574, 175, 580, 173, 590, 171, 597, 167, 606, 167, 613, 168, 623, 170, 635, 170, 638, 171, 644, 169, 654, 169, 668, 168, 679, 165, 691, 161, 703, 162, 710, 162, 723, 162, 731, 163, 737, 165, 743, 169, 750, 172, 755, 169, 762, 169, 774, 168, 784, 168, 789, 167, 802, 167, 807, 164, 815, 163, 818, 159, 825, 157, 825, 150, 825, 149, 825, 145, 825, 143, 823, 140, 824, 139, 824, 135, 824, 131, 824, 127, 821, 120, 818, 118, 816, 116, 812, 115, 804, 115, 797, 119, 792, 126, 782, 130, 776, 134, 768, 133, 762, 132, 748, 132, 737, 130, 723, 129, 716, 128, 707, 124, 695, 123, 685, 120, 677, 117, 664, 116, 658, 114, 646, 114, 640, 115, 631, 117, 615, 119, 604, 118, 586, 119, 570, 120, 558, 123, 546, 120, 534, 116, 514, 115, 502, 112, 484, 112, 475, 112, 472, 113, 458, 113, 442, 114, 428, 117, 416, 121, 401, 125, 389, 131, 375\" />"; $area[3] = "<area href=\"#\" part=\"D\" data-part=\"Dos\" shape=\"poly\" coords=\"132, 359, 153, 363, 172, 366, 191, 367, 211, 368, 232, 366, 251, 362, 263, 359, 269, 353, 270, 341, 270, 330, 268, 321, 266, 307, 268, 298, 273, 285, 278, 274, 277, 259, 276, 247, 275, 239, 275, 231, 275, 223, 274, 213, 274, 196, 274, 185, 273, 174, 272, 163, 271, 152, 270, 143, 259, 139, 250, 136, 243, 133, 230, 139, 218, 141, 210, 142, 179, 141, 171, 139, 163, 136, 157, 133, 147, 138, 139, 141, 134, 143, 133, 152, 132, 170, 132, 177, 131, 199, 131, 211, 130, 225, 130, 236, 128, 247, 128, 259, 127, 268, 127, 277, 130, 286, 134, 293, 136, 302, 135, 312, 134, 324, 134, 336, 133, 347\" />"; $area[4] = "<area href=\"#\" part=\"C\" data-part=\"Cou\" shape=\"poly\" coords=\"167, 94, 173, 97, 181, 103, 190, 110, 202, 114, 213, 111, 222, 106, 229, 97, 234, 96, 233, 104, 233, 116, 234, 124, 236, 129, 239, 131, 232, 136, 222, 138, 211, 139, 201, 139, 193, 139, 182, 139, 173, 137, 167, 134, 161, 131, 161, 130, 167, 127, 170, 124, 170, 117, 170, 111, 169, 105, 168, 100\" />"; $area[5] = "<area href=\"#\" part=\"MSD\" data-part=\"Membre supérieur Droit\" shape=\"poly\" coords=\"273, 144, 288, 147, 297, 151, 306, 155, 312, 165, 318, 183, 322, 195, 324, 210, 322, 221, 325, 231, 328, 245, 327, 255, 330, 267, 333, 279, 336, 289, 341, 309, 345, 325, 348, 344, 348, 360, 352, 375, 356, 391, 322, 402, 318, 393, 313, 381, 307, 372, 301, 359, 296, 351, 293, 340, 291, 329, 289, 314, 287, 295, 285, 286, 282, 276, 279, 266\" />"; $area[6] = "<area href=\"#\" part=\"MSG\" data-part=\"Membre supérieur Gauche\" shape=\"poly\" coords=\"125, 268, 119, 284, 116, 299, 112, 322, 112, 333, 108, 345, 101, 357, 95, 375, 84, 394, 79, 404, 48, 395, 53, 368, 54, 356, 58, 331, 60, 316, 63, 302, 66, 290, 72, 280, 73, 264, 76, 251, 80, 231, 82, 222, 83, 213, 82, 192, 83, 186, 87, 177, 92, 163, 101, 155, 111, 149, 123, 145, 131, 144\" />"; Then set some styles according to TCPDF and your needs : // your style $style['green'] = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 230, 0)); $style['orange'] = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(242, 169, 33)); $style['red'] = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 33, 33)); $colorGreen = array(198, 237, 189); $colorOrange = array(239, 222, 189); $colorRed = array(239, 184, 184); Then add thoses functions : function areaToPolygon($pdfObj, $area, $style, $fillColor) { $pdfObj->Polygon($area, 'DF', array('all' => $style), $fillColor); } function parseArrayArea($html) { $matches = array(); preg_match('/coords=.*"/', $html, $matches); $area = array_map('intval', array_map('trim', explode(',', str_replace('"', '', str_replace('coords="','', $matches[0]))))); $area = array_map('parseAreaPoint', $area); return $area; } function parseAreaPoint($point) { return $point/2; } In parseAreaPoint function, you can modify to your needs the division. like ($point/3) Finally call the functions like following : (do this in a loop please because it hurts my eyes lol BTW it's an exemple so it doesn't matter) $parsed_area = parseArrayArea($area[0]); areaToPolygon($pdf, $parsed_area, $style['green'], $colorGreen); $parsed_area = parseArrayArea($area[1]); areaToPolygon($pdf, $parsed_area, $style['orange'], $colorOrange); $parsed_area = parseArrayArea($area[2]); areaToPolygon($pdf, $parsed_area, $style['red'], $colorRed); $parsed_area = parseArrayArea($area[3]); areaToPolygon($pdf, $parsed_area, $style['green'], $colorGreen); $parsed_area = parseArrayArea($area[4]); areaToPolygon($pdf, $parsed_area, $style['orange'], $colorOrange); $parsed_area = parseArrayArea($area[5]); areaToPolygon($pdf, $parsed_area, $style['red'], $colorRed); $parsed_area = parseArrayArea($area[6]); areaToPolygon($pdf, $parsed_area, $style['green'], $colorGreen); Here you have it ! see body map I hope this helps you. :) You can work around those codes. If you have any further questions, please do not hesitate. EDIT : You can also modify parseAreaPoint a bit if you need to move on x/y Axis. (x and y axis in area work like that : x1, y1, x2, y2 ...)
Trial Division Prime Factorization using PHP
I'm currently working on a function to get prime factors by trial division of a number (particularly a large number) and I am stumped by my results. Below is my PHP code. I was able to get the correct results with a javascript variant of this code but PHP does not give me the results. function primeFactors($n) { $primeNumbers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]; $factors = []; for ($i = 0, $p=$primeNumbers[$i]; $i < count($primeNumbers) && $p*$p<=$n; $i++, $p=$primeNumbers[$i]) { while ($n % $p == 0) { $factors[] = $n; $n = $n /$p; } } if ($n>1) { $factors[] = $n; } var_dump($factors); return $factors; } Appreciate It.
You're adding the wrong number into the factors array... $factors[] = $n; Is adding the original number in, think you meant to add the factor in $factors[] = $p; This is a good example (IMHO) of giving fields meaningful names as this would have been more obvious.
Duplicate SKU in rows: in magento csv import
When importing products in Magento Admin Panel, it shows the error Duplicate SKU in rows. Magento csv import: Duplicate SKU in rows: 76, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 109, 110, 120, 121, 122, 123, 125, 126, 129, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 167, 169, 171, 172, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 189
it will be due to duplicate values for sku in your importing csv file,